MCPcopy Create free account
hub / github.com/brimdata/super / TrueCount

Method TrueCount

vector/bitvec/bits.go:94–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func (b Bits) TrueCount() uint32 {
95 if b.IsZero() {
96 return 0
97 }
98 var n uint32
99 for _, bs := range b.bits {
100 n += uint32(bits.OnesCount64(bs))
101 }
102 if numTailBits := b.Len() % 64; numTailBits > 0 {
103 mask := ^uint64(0) << numTailBits
104 unusedBits := b.bits[len(b.bits)-1] & mask
105 n -= uint32(bits.OnesCount64(unusedBits))
106 }
107 return n
108}
109
110// helpful to have around for debugging
111func (b Bits) String() string {

Callers 3

TestBitsTrueCountFunction · 0.80
evalForListMethod · 0.80
listHasErrorFunction · 0.80

Calls 2

IsZeroMethod · 0.95
LenMethod · 0.95

Tested by 1

TestBitsTrueCountFunction · 0.64