(x uint16)
| 1308 | } |
| 1309 | |
| 1310 | func (bc *bitmapContainer) addOffset(x uint16) (container, container) { |
| 1311 | var low, high *bitmapContainer |
| 1312 | |
| 1313 | if bc.cardinality == 0 { |
| 1314 | return nil, nil |
| 1315 | } |
| 1316 | |
| 1317 | b := uint32(x) >> 6 |
| 1318 | i := uint32(x) % 64 |
| 1319 | end := uint32(1024) - b |
| 1320 | |
| 1321 | low = newBitmapContainer() |
| 1322 | if i == 0 { |
| 1323 | copy(low.bitmap[b:], bc.bitmap[:end]) |
| 1324 | } else { |
| 1325 | low.bitmap[b] = bc.bitmap[0] << i |
| 1326 | for k := uint32(1); k < end; k++ { |
| 1327 | newval := bc.bitmap[k] << i |
| 1328 | newval |= bc.bitmap[k-1] >> (64 - i) |
| 1329 | low.bitmap[b+k] = newval |
| 1330 | } |
| 1331 | } |
| 1332 | low.computeCardinality() |
| 1333 | |
| 1334 | if low.cardinality == bc.cardinality { |
| 1335 | // All elements from bc ended up in low, meaning high will be empty. |
| 1336 | return low, nil |
| 1337 | } |
| 1338 | |
| 1339 | if low.cardinality == 0 { |
| 1340 | // low is empty, let's reuse the container for high. |
| 1341 | high = low |
| 1342 | low = nil |
| 1343 | } else { |
| 1344 | // None of the containers will be empty, so allocate both. |
| 1345 | high = newBitmapContainer() |
| 1346 | } |
| 1347 | |
| 1348 | if i == 0 { |
| 1349 | copy(high.bitmap[:b], bc.bitmap[end:]) |
| 1350 | } else { |
| 1351 | for k := end; k < 1024; k++ { |
| 1352 | newval := bc.bitmap[k] << i |
| 1353 | newval |= bc.bitmap[k-1] >> (64 - i) |
| 1354 | high.bitmap[k-end] = newval |
| 1355 | } |
| 1356 | high.bitmap[b] = bc.bitmap[1023] >> (64 - i) |
| 1357 | } |
| 1358 | high.computeCardinality() |
| 1359 | |
| 1360 | // Ensure proper nil interface. |
| 1361 | if low == nil { |
| 1362 | return nil, high |
| 1363 | } |
| 1364 | |
| 1365 | return low, high |
| 1366 | } |
| 1367 |
nothing calls this directly
no test coverage detected