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

Method SetBit

bitarray/bitarray.go:87–107  ·  view source on GitHub ↗

SetBit sets a bit at the given index to true.

(k uint64)

Source from the content-addressed store, hash-verified

85
86// SetBit sets a bit at the given index to true.
87func (ba *bitArray) SetBit(k uint64) error {
88 if k >= ba.Capacity() {
89 return OutOfRangeError(k)
90 }
91
92 if !ba.anyset {
93 ba.lowest = k
94 ba.highest = k
95 ba.anyset = true
96 } else {
97 if k < ba.lowest {
98 ba.lowest = k
99 } else if k > ba.highest {
100 ba.highest = k
101 }
102 }
103
104 i, pos := getIndexAndRemainder(k)
105 ba.blocks[i] = ba.blocks[i].insert(pos)
106 return nil
107}
108
109// GetBit returns a bool indicating if the value at the given
110// index has been set.

Callers

nothing calls this directly

Calls 4

CapacityMethod · 0.95
OutOfRangeErrorTypeAlias · 0.85
getIndexAndRemainderFunction · 0.85
insertMethod · 0.65

Tested by

no test coverage detected