MCPcopy Create free account
hub / github.com/tendermint/tendermint / IsFull

Method IsFull

libs/bits/bit_array.go:226–244  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

224
225// IsFull returns true iff all bits in the bit array are 1.
226func (bA *BitArray) IsFull() bool {
227 if bA == nil {
228 return true
229 }
230 bA.mtx.Lock()
231 defer bA.mtx.Unlock()
232
233 // Check all elements except the last
234 for _, elem := range bA.Elems[:len(bA.Elems)-1] {
235 if (^elem) != 0 {
236 return false
237 }
238 }
239
240 // Check that the last element has (lastElemBits) 1's
241 lastElemBits := (bA.Bits+63)%64 + 1
242 lastElem := bA.Elems[len(bA.Elems)-1]
243 return (lastElem+1)&((uint64(1)<<uint(lastElemBits))-1) == 0
244}
245
246// PickRandom returns a random index for a set bit in the bit array.
247// 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