GetBit key offset bitvalye offset / 8 > the index of value offset mod 8 +1
(offset int)
| 217 | // offset / 8 > the index of value |
| 218 | // offset mod 8 +1 |
| 219 | func (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. |
| 235 | func (s *String) BitCount(begin, end int) (int, error) { |
no outgoing calls