fixed

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

func AndBitmaps

func AndBitmaps(nbits int, bitmaps ...*Bitmap) *Bitmap

And computes the intersection between the bitmaps and returns the result.

func AndNotBitmap

func AndNotBitmap(a *Bitmap, b *Bitmap) *Bitmap

AndNot computes the difference between the bitmaps and returns the result.

func FlipBitmap

func FlipBitmap(b *Bitmap, start, stop int) *Bitmap

FlipBitmap negates the bits in the the bitmaps range and returns the result.

func NewBitmap

func NewBitmap(nbits int) *Bitmap

NewBitmap returns a fixed size bitmap with a capacity for nbits of storage.

func NewBitmapFromBuf

func NewBitmapFromBuf(buf []byte, nbits int, copyBuffer bool) (*Bitmap, error)

NewBitmapFromBuf returns a fixed size bitmap with a capacity for nbits of storage. The bitmap is initialized from the marshaled form. If copyBuffer is true, the buffer is copied, otherwise it may be used by the bitmap itself.

func OrBitmaps

func OrBitmaps(nbits int, bitmaps ...*Bitmap) *Bitmap

Or computes the union between the bitmaps and stores the returns the result.

func (*Bitmap) Add

func (b *Bitmap) Add(v uint32) bool

Add the integer x to the bitmap.

func (*Bitmap) AddInt

func (b *Bitmap) AddInt(v int) bool

AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint32 and we call Add).

func (*Bitmap) And

func (b *Bitmap) And(o *Bitmap)

And computes the intersection between two bitmaps and stores the result in the current bitmap.

func (*Bitmap) AndNot

func (b *Bitmap) AndNot(o *Bitmap)

Or computes the union between two bitmaps and stores the result in the current bitmap.

func (*Bitmap) Bytes

func (b *Bitmap) Bytes() []byte

Bytes returns a pointer to the content of the bitmap.

func (*Bitmap) Clear

func (b *Bitmap) Clear()

Clear sets all bits to 0.

func (*Bitmap) Clone

func (b *Bitmap) Clone() *Bitmap

Clone creates a copy of the bitmap.

func (*Bitmap) Contains

func (b *Bitmap) Contains(v uint32) bool

Contains returns true if the integer is contained in the bitmap.

func (*Bitmap) Equals

func (b *Bitmap) Equals(o *Bitmap) bool

Equals returns true if the two bitmaps are the same, false otherwise.

func (*Bitmap) FlipInt

func (b *Bitmap) FlipInt(start, stop int)

Flip negates the bits in the given range (i.e., [start,stop)), any integer present in this range and in the bitmap is removed, and any integer present in the range and not in the bitmap is added.

func (*Bitmap) GetCardinality

func (b *Bitmap) GetCardinality() uint64

GetCardinality returns the number of integers contained in the bitmap.

func (*Bitmap) IsEmpty

func (b *Bitmap) IsEmpty() bool

IsEmpty returns true if the Bitmap is empty.

func (*Bitmap) Marshal

func (b *Bitmap) Marshal() ([]byte, error)

Marshal returns a binary encoding of the bitmap. The data returned may point to the internals of the bitmap itself, and if the bitmap is subsequently changed the marshaled form may change.

func (*Bitmap) NextMany

func (b *Bitmap) NextMany(i uint32, buffer []uint32, limit int) ([]uint32, bool)

NextMany appends many next bit sets from the specified index, including possibly the current index and up to limit. If more is true, there are additional bits to be added.

   buffer := uint32{}
   j := uint32(0)
	  for {
		  var more bool
		  buf, more = v.NextMany2(j, buf, 10)
		  if !more {
			  break
		  }
       do something with buf
       buf = buf[:0] // possible clear buffer
		  j = buf[len(buf)-1] + 1
	}

It is possible to retrieve all set bits as follow:

indices := make([]uint32, 0, bitmap.Count())
bitmap.NextMany2(0, indices, bitmap.Count())

However if bitmap.Count() is large, it might be preferable to use several calls to NextMany2, for performance reasons.

func (*Bitmap) Or

func (b *Bitmap) Or(o *Bitmap)

Or computes the union between two bitmaps and stores the result in the current bitmap.

func (*Bitmap) Remove

func (b *Bitmap) Remove(v uint32) bool

Remove the integer x from the bitmap.

func (*Bitmap) ToArray

func (b *Bitmap) ToArray() []uint32

ToArray creates a new slice containing all of the integers stored in the Bitmap in sorted order

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL