Skip to content

0xc0392b/bfield

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

go get github.com/williamsandytoes/bfield

Example usage

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
}

Releases

No releases published

Packages

No packages published

Languages