MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / IsFull

Method IsFull

libs/bits/bit_array.go:221–239  ·  view source on GitHub ↗

IsFull returns true iff all bits in the bit array are 1.

()

Source from the content-addressed store, hash-verified

219
220// IsFull returns true iff all bits in the bit array are 1.
221func (bA *BitArray) IsFull() bool {
222 if bA == nil {
223 return true
224 }
225 bA.mtx.Lock()
226 defer bA.mtx.Unlock()
227
228 // Check all elements except the last
229 for _, elem := range bA.Elems[:len(bA.Elems)-1] {
230 if (^elem) != 0 {
231 return false
232 }
233 }
234
235 // Check that the last element has (lastElemBits) 1's
236 lastElemBits := (bA.Bits+63)%64 + 1
237 lastElem := bA.Elems[len(bA.Elems)-1]
238 return (lastElem+1)&((uint64(1)<<uint(lastElemBits))-1) == 0
239}
240
241// PickRandom returns a random index for a set bit in the bit array.
242// If there is no such value, it returns 0, false.

Callers 1

TestEmptyFullFunction · 0.95

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by 1

TestEmptyFullFunction · 0.76