MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / setBit

Method setBit

structure/bitmap_1.go:319–330  ·  view source on GitHub ↗

Set the value of a specific bit, assuming the value is valid

(bitmap []byte, offset uint, value bool)

Source from the content-addressed store, hash-verified

317
318// Set the value of a specific bit, assuming the value is valid
319func (b *BitMapStructure) setBit(bitmap []byte, offset uint, value bool) {
320 index := offset / 8
321 bit := uint(offset % 8)
322
323 if value {
324 // Set the bit at the offset to 1
325 bitmap[index] |= 1 << bit
326 } else {
327 // Set the bit at the offset to 0
328 bitmap[index] &= ^(1 << bit)
329 }
330}
331
332// Get the value of a specific bit, assuming the value is valid
333func (b *BitMapStructure) getBit(bitmap []byte, offset uint) bool {

Callers 5

SetBitMethod · 0.95
SetBitsMethod · 0.95
BitOpMethod · 0.95
BitDelMethod · 0.95
BitDelsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected