MCPcopy Index your code
hub / github.com/Workiva/go-datastructures / ClearBit

Method ClearBit

bitarray/bitarray.go:189–207  ·  view source on GitHub ↗

ClearBit will unset a bit at the given index if it is set.

(k uint64)

Source from the content-addressed store, hash-verified

187
188// ClearBit will unset a bit at the given index if it is set.
189func (ba *bitArray) ClearBit(k uint64) error {
190 if k >= ba.Capacity() {
191 return OutOfRangeError(k)
192 }
193
194 if !ba.anyset { // nothing is set, might as well bail
195 return nil
196 }
197
198 i, pos := getIndexAndRemainder(k)
199 ba.blocks[i] &^= block(1 << pos)
200
201 if k == ba.highest {
202 ba.setHighest()
203 } else if k == ba.lowest {
204 ba.setLowest()
205 }
206 return nil
207}
208
209// Count returns the number of set bits in this array.
210func (ba *bitArray) Count() int {

Callers

nothing calls this directly

Calls 6

CapacityMethod · 0.95
setHighestMethod · 0.95
setLowestMethod · 0.95
OutOfRangeErrorTypeAlias · 0.85
getIndexAndRemainderFunction · 0.85
blockTypeAlias · 0.85

Tested by

no test coverage detected