https://github.com/0xc0392b/bfield
Bit field data structure for Go
https://github.com/0xc0392b/bfield
bit-manipulation bitfield data-structures go golang
Last synced: 2 months ago
JSON representation
Bit field data structure for Go
- Host: GitHub
- URL: https://github.com/0xc0392b/bfield
- Owner: 0xc0392b
- License: mit
- Created: 2018-09-12T00:47:43.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-10T19:14:44.000Z (over 6 years ago)
- Last Synced: 2023-07-11T20:45:29.341Z (over 2 years ago)
- Topics: bit-manipulation, bitfield, data-structures, go, golang
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bfield
### Bit field data structure for Go
#### Methods
* Toggle(index) -> toggles the state of a bit at a specific index
* Get(index) -> retrieve the state of a bit at a specific index
* Set(index, state) -> sets the state of a bit at a specific index
#### Installation
```text
go get github.com/williamsandytoes/bfield
```
#### Example usage
```go
package main
import (
"fmt"
"github.com/williamsandytoes/bfield"
)
func main() {
b := bfield.New(1000)
b.Toggle(10)
fmt.Println(b.Get(10)) // true
b.Toggle(10)
fmt.Println(b.Get(10)) // false
}
```