MCPcopy Create free account
hub / github.com/distributedio/titan / GetBit

Method GetBit

db/string.go:219–232  ·  view source on GitHub ↗

GetBit key offset bitvalye offset / 8 > the index of value offset mod 8 +1

(offset int)

Source from the content-addressed store, hash-verified

217// offset / 8 > the index of value
218// offset mod 8 +1
219func (s *String) GetBit(offset int) (int, error) {
220 val := s.Meta.Value
221 bitoff := offset >> 3
222 if int(bitoff) > len(val)-1 {
223 return 0, nil
224 }
225
226 /* Get current values */
227 byteval := int(val[bitoff])
228 bit := uint(7 - (offset & 0x7))
229 bitval := byteval & (1 << bit)
230
231 return bitval, nil
232}
233
234// BitCount counts the number of set bits (population counting) in a string.
235func (s *String) BitCount(begin, end int) (int, error) {

Callers 2

GetBitFunction · 0.80
TestStringGetBitFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestStringGetBitFunction · 0.64