Documentation
¶
Overview ¶
Package bitmap provides the implementation of bitmap.
Index ¶
- Constants
- func FormatList(b *Bitmap) string
- type Bitmap
- func (b *Bitmap) Add(i uint32)
- func (b *Bitmap) ClearRange(begin, end uint32)
- func (b *Bitmap) Clone() Bitmap
- func (b *Bitmap) FirstOne(start uint32) (bit uint32, err error)
- func (b *Bitmap) FirstZero(start uint32) (bit uint32, err error)
- func (b *Bitmap) FlipRange(begin, end uint32)
- func (b *Bitmap) ForEach(start, end uint32, f func(idx uint32) bool)
- func (b *Bitmap) GetNumOnes() uint32
- func (b *Bitmap) Grow(toGrow uint32) error
- func (b *Bitmap) IsEmpty() bool
- func (b *Bitmap) Maximum() uint32
- func (b *Bitmap) Minimum() uint32
- func (b *Bitmap) Remove(i uint32)
- func (b *Bitmap) Reset()
- func (b *Bitmap) Size() int
- func (b *Bitmap) ToSlice() []uint32
Constants ¶
const MaxBitEntryLimit uint32 = math.MaxInt32
MaxBitEntryLimit defines the upper limit on how many bit entries are supported by this Bitmap implementation.
Variables ¶
This section is empty.
Functions ¶
func FormatList ¶
FormatList produces a string representation of b, which lists the indices of set bits in the bitmap. Indices are separated by commas and ranges of set bits are abbreviated. Example outputs: "0,2,4", "0,3-7,10", "0-10".
Inverse of ParseList.
Types ¶
type Bitmap ¶
type Bitmap struct {
// contains filtered or unexported fields
}
Bitmap implements an efficient bitmap.
+stateify savable
func ParseList ¶
ParseList parses input as a bitmap. input should be a comma separated list of indices, and ranges of set bits may be abbreviated. Examples: "0,2,4", "0,3-7,10", "0-10". Input after the first newline or null byte is discarded.
sizeHint sets the initial size of the bitmap, which may prevent reallocation when growing the bitmap during parsing. Ideally sizeHint should be at least as large as the bitmap represented by input, but this is not required.
Inverse of FormatList.
func (*Bitmap) ClearRange ¶
ClearRange clear bits within range (begin and end) for the Bitmap. begin is inclusive and end is exclusive.
func (*Bitmap) FlipRange ¶
FlipRange flip bits within range (begin and end) for the Bitmap. begin is inclusive and end is exclusive.
func (*Bitmap) ForEach ¶
ForEach calls `f` for each set bit in the range [start, end).
If f returns false, ForEach stops the iteration.
func (*Bitmap) GetNumOnes ¶
GetNumOnes return the number of ones in the Bitmap.