CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present)
(x uint32)
| 1186 | |
| 1187 | // CheckedAdd adds the integer x to the bitmap and return true if it was added (false if the integer was already present) |
| 1188 | func (rb *Bitmap) CheckedAdd(x uint32) bool { |
| 1189 | // TODO: add unit tests for this method |
| 1190 | hb := highbits(x) |
| 1191 | i := rb.highlowcontainer.getIndex(hb) |
| 1192 | if i >= 0 { |
| 1193 | C := rb.highlowcontainer.getWritableContainerAtIndex(i) |
| 1194 | oldcard := C.getCardinality() |
| 1195 | C = C.iaddReturnMinimized(lowbits(x)) |
| 1196 | rb.highlowcontainer.setContainerAtIndex(i, C) |
| 1197 | return C.getCardinality() > oldcard |
| 1198 | } |
| 1199 | newac := newArrayContainer() |
| 1200 | rb.highlowcontainer.insertNewKeyValueAt(-i-1, hb, newac.iaddReturnMinimized(lowbits(x))) |
| 1201 | return true |
| 1202 | } |
| 1203 | |
| 1204 | // AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint32 and we call Add) |
| 1205 | func (rb *Bitmap) AddInt(x int) { |
nothing calls this directly
no test coverage detected