BitCount counts the number of set bits (population counting) in a string.
(begin, end int)
| 233 | |
| 234 | // BitCount counts the number of set bits (population counting) in a string. |
| 235 | func (s *String) BitCount(begin, end int) (int, error) { |
| 236 | begin, end = initCursor(begin, end, len(s.Meta.Value)) |
| 237 | if begin > end { |
| 238 | return 0, nil |
| 239 | } |
| 240 | return redisPopcount(s.Meta.Value[begin : end+1]), nil |
| 241 | } |
| 242 | |
| 243 | // BitPos finds first bit set or clear in a string |
| 244 | func (s *String) BitPos(bit, begin, end int) (int, error) { |