BitDel delete the bit at the specified offset in the bitmap If the key does not exist, it returns an error There is room for optimization
(key string, offset uint)
| 254 | // If the key does not exist, it returns an error |
| 255 | // There is room for optimization |
| 256 | func (b *BitMapStructure) BitDel(key string, offset uint) error { |
| 257 | |
| 258 | bitmap, length, err := b.getBitmapFromDB(key, false) |
| 259 | if err != nil { |
| 260 | return err |
| 261 | } |
| 262 | // If offset is greater than or equal to length, no operation is needed |
| 263 | if offset >= length { |
| 264 | return nil |
| 265 | } |
| 266 | |
| 267 | length-- |
| 268 | // Shift the bits one by one |
| 269 | for i := offset; i < length; i++ { |
| 270 | b.setBit(bitmap, i, b.getBit(bitmap, i+1)) |
| 271 | } |
| 272 | |
| 273 | return b.setBitmapToDB(key, bitmap, length) |
| 274 | } |
| 275 | |
| 276 | // BitDels delete a group of bits at the specified offsets in the bitmap |
| 277 | // If the key does not exist, it returns an error |