https://github.com/damnever/bitarray
BitArray for Golang
https://github.com/damnever/bitarray
bitarray golang hamming-weight
Last synced: 2 months ago
JSON representation
BitArray for Golang
- Host: GitHub
- URL: https://github.com/damnever/bitarray
- Owner: damnever
- License: other
- Created: 2016-09-23T17:25:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-23T12:22:03.000Z (almost 6 years ago)
- Last Synced: 2025-03-23T19:51:21.362Z (3 months ago)
- Topics: bitarray, golang, hamming-weight
- Language: Go
- Homepage: https://github.com/damnever/bitarray
- Size: 8.79 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## BitArray for Golang [](https://travis-ci.org/damnever/bitarray) [](https://godoc.org/github.com/damnever/bitarray)
### Installation
```
go get github.com/damnever/bitarray
```### Example
```go
package mainimport "github.com/damnever/bitarray"
func main() {
bits := bitarray.New(64)bits.Put(8, 1) // set value of the bit to 1 by index 8, return old bit.
bits.Get(8) // get value of the bit by index 8
bits.Set(9, 16) // set all bits to 1 between 9 and 16 , both 9 and 16 included.
bits.Count() // get the count of bit 1
// Clear/Not/Eq/Leq/Lt/ToArray ...
}
```