Documentation ¶
Index ¶
- type Bitmap
- func AndBitmaps(nbits int, bitmaps ...*Bitmap) *Bitmap
- func AndNotBitmap(a *Bitmap, b *Bitmap) *Bitmap
- func FlipBitmap(b *Bitmap, start, stop int) *Bitmap
- func NewBitmap(nbits int) *Bitmap
- func NewBitmapFromBuf(buf []byte, nbits int, copyBuffer bool) (*Bitmap, error)
- func OrBitmaps(nbits int, bitmaps ...*Bitmap) *Bitmap
- func (b *Bitmap) Add(v uint32) bool
- func (b *Bitmap) AddInt(v int) bool
- func (b *Bitmap) And(o *Bitmap)
- func (b *Bitmap) AndNot(o *Bitmap)
- func (b *Bitmap) Bytes() []byte
- func (b *Bitmap) Clear()
- func (b *Bitmap) Clone() *Bitmap
- func (b *Bitmap) Contains(v uint32) bool
- func (b *Bitmap) Equals(o *Bitmap) bool
- func (b *Bitmap) FlipInt(start, stop int)
- func (b *Bitmap) GetCardinality() uint64
- func (b *Bitmap) IsEmpty() bool
- func (b *Bitmap) Marshal() ([]byte, error)
- func (b *Bitmap) NextMany(i uint32, buffer []uint32, limit int) ([]uint32, bool)
- func (b *Bitmap) Or(o *Bitmap)
- func (b *Bitmap) Remove(v uint32) bool
- func (b *Bitmap) ToArray() []uint32
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 ¶
And computes the intersection between the bitmaps and returns the result.
func AndNotBitmap ¶
AndNot computes the difference between the bitmaps and returns the result.
func FlipBitmap ¶
FlipBitmap negates the bits in the the bitmaps range and returns the result.
func NewBitmapFromBuf ¶
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 (*Bitmap) AddInt ¶
AddInt adds the integer x to the bitmap (convenience method: the parameter is casted to uint32 and we call Add).
func (*Bitmap) And ¶
And computes the intersection between two bitmaps and stores the result in the current bitmap.
func (*Bitmap) AndNot ¶
Or computes the union between two bitmaps and stores the result in the current bitmap.
func (*Bitmap) FlipInt ¶
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 ¶
GetCardinality returns the number of integers contained in the bitmap.
func (*Bitmap) Marshal ¶
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 ¶
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 ¶
Or computes the union between two bitmaps and stores the result in the current bitmap.