Documentation ¶
Overview ¶
Package bitmap provides a datatype for long vectors of bits.
Index ¶
- Variables
- type Bitmap
- func (h *Bitmap) Bits() uint64
- func (h *Bitmap) IsSet(ordinal uint64) bool
- func (h *Bitmap) MarshalBinary() ([]byte, error)
- func (h *Bitmap) MarshalJSON() ([]byte, error)
- func (h *Bitmap) Set(ordinal uint64) error
- func (h *Bitmap) SetAny(serial bool) (uint64, error)
- func (h *Bitmap) SetAnyInRange(start, end uint64, serial bool) (uint64, error)
- func (h *Bitmap) String() string
- func (h *Bitmap) UnmarshalBinary(ba []byte) error
- func (h *Bitmap) UnmarshalJSON(data []byte) error
- func (h *Bitmap) Unselected() uint64
- func (h *Bitmap) Unset(ordinal uint64) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoBitAvailable is returned when no more bits are available to set ErrNoBitAvailable = errors.New("no bit available") // ErrBitAllocated is returned when the specific bit requested is already set ErrBitAllocated = errors.New("requested bit is already allocated") )
Functions ¶
This section is empty.
Types ¶
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap is a fixed-length bit vector. It is not safe for concurrent use.
The data is stored as a list of run-length encoded blocks. It operates directly on the encoded representation, without decompressing.
func (*Bitmap) IsSet ¶
IsSet atomically checks if the ordinal bit is set. In case ordinal is outside of the bit sequence limits, false is returned.
func (*Bitmap) MarshalBinary ¶
MarshalBinary encodes h into a binary representation.
func (*Bitmap) MarshalJSON ¶
MarshalJSON encodes h into a JSON message
func (*Bitmap) SetAny ¶
SetAny sets the first unset bit in the sequence and returns the ordinal of the set bit.
When serial=true, the bitmap is scanned starting from the ordinal following the bit most recently set by Bitmap.SetAny or Bitmap.SetAnyInRange.
func (*Bitmap) SetAnyInRange ¶
SetAnyInRange sets the first unset bit in the range [start, end] and returns the ordinal of the set bit.
When serial=true, the bitmap is scanned starting from the ordinal following the bit most recently set by Bitmap.SetAny or Bitmap.SetAnyInRange.
func (*Bitmap) UnmarshalBinary ¶
UnmarshalBinary decodes a binary representation of a Bitmap value which was generated using Bitmap.MarshalBinary.
The scan position for serial Bitmap.SetAny and Bitmap.SetAnyInRange operations is neither unmarshaled nor reset.
func (*Bitmap) UnmarshalJSON ¶
UnmarshalJSON decodes JSON message into h
func (*Bitmap) Unselected ¶
Unselected returns the number of bits which are not selected