CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present)
(x uint64)
| 334 | |
| 335 | // CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present) |
| 336 | func (rb *Bitmap) CheckedAdd(x uint64) bool { |
| 337 | hb := highbits(x) |
| 338 | i := rb.highlowcontainer.getIndex(hb) |
| 339 | if i >= 0 { |
| 340 | c := rb.highlowcontainer.getWritableContainerAtIndex(i) |
| 341 | return c.CheckedAdd(lowbits(x)) |
| 342 | } |
| 343 | newBitmap := roaring.NewBitmap() |
| 344 | newBitmap.Add(lowbits(x)) |
| 345 | rb.highlowcontainer.insertNewKeyValueAt(-i-1, hb, newBitmap) |
| 346 | return true |
| 347 | } |
| 348 | |
| 349 | // AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint64 and we call Add) |
| 350 | func (rb *Bitmap) AddInt(x int) { |