Back to

Package bitmap

Latest Go to latest

The latest major version is v2.

Published: Feb 21, 2020 | License: MIT | Module:


Package bitmap provides a []bool/bitmap implementation with standardized iteration. Bitmaps are the equivalent of []bool, with improved compression for runs of similar values, and faster operations on ranges and the like.



const MaxInt = -1


var ToEnd int = -1

type BitIndex

type BitIndex = int

type Bitmap

type Bitmap struct {
	RB *roaring.Bitmap

Bitmaps store the existence of values in [0,math.MaxUint32] more efficiently than []bool. The empty value starts with no bits set.

func Flip

func Flip(bm Bitmap, start, end int) Bitmap

func Sub

func Sub(left, right Bitmap) Bitmap

func (*Bitmap) Add

func (me *Bitmap) Add(is ...BitIndex)

func (*Bitmap) AddRange

func (me *Bitmap) AddRange(begin, end BitIndex)

func (*Bitmap) Clear

func (me *Bitmap) Clear()

func (Bitmap) Contains

func (me Bitmap) Contains(i int) bool

func (Bitmap) Copy

func (me Bitmap) Copy() (ret Bitmap)

func (*Bitmap) FlipRange

func (me *Bitmap) FlipRange(begin, end BitIndex)

func (Bitmap) Get

func (me Bitmap) Get(bit BitIndex) bool

func (Bitmap) IsEmpty

func (me Bitmap) IsEmpty() bool

func (Bitmap) Iter

func (me Bitmap) Iter(cb iter.Callback)

func (Bitmap) IterTyped

func (me Bitmap) IterTyped(f func(int) bool) bool

Returns true if all values were traversed without early termination.

func (Bitmap) Len

func (me Bitmap) Len() int

The number of set bits in the bitmap. Also known as cardinality.

func (*Bitmap) Remove

func (me *Bitmap) Remove(i BitIndex) bool

func (*Bitmap) RemoveRange

func (me *Bitmap) RemoveRange(begin, end BitIndex) *Bitmap

func (*Bitmap) Set

func (me *Bitmap) Set(bit BitIndex, value bool)

func (*Bitmap) Sub

func (me *Bitmap) Sub(other Bitmap)

func (Bitmap) ToSortedSlice

func (me Bitmap) ToSortedSlice() (ret []int)

func (*Bitmap) Union

func (me *Bitmap) Union(other Bitmap)

type Interface

type Interface interface {
	Len() int

type Iter

type Iter struct {
	// contains filtered or unexported fields

func (*Iter) Next

func (me *Iter) Next() bool

func (*Iter) Stop

func (me *Iter) Stop()

func (*Iter) Value

func (me *Iter) Value() interface{}

func (*Iter) ValueInt

func (me *Iter) ValueInt() int

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier