Documentation ¶
Overview ¶
Contains efficient array that stores small-range values (up to uint64) in a bit array to optimize storage.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitSet ¶
type BitSet []Block
BitSet is a set of bits that can be set, cleared and queried.
Example ¶
s := new(BitSet) s.Set(13) s.Set(45) s.Clear(13) fmt.Printf("s.IsSet(13) = %t; s.IsSet(45) = %t; s.IsSet(30) = %t\n", s.IsSet(13), s.IsSet(45), s.IsSet(30))
Output: s.IsSet(13) = false; s.IsSet(45) = true; s.IsSet(30) = false
func (*BitSet) BlockCount ¶
Returns the number of blocks of the BitSet.
func (BitSet) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BitSet.
func (BitSet) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type CompactArray ¶
type CompactArray struct { *BitSet `json:",inline"` ItemSize uint `json:"item,omitempty"` ItemsCount uint `json:"count,omitempty"` }
Provides a wrapper on top of BitSet to store items of arbitrary size (up to 64 bits each) efficiently.
func NewCompactArray ¶
func NewCompactArray(size uint, maxValue Item) (CompactArray, error)
Creates a new CompactArray of specified size.
func (*CompactArray) DeepCopy ¶
func (a *CompactArray) DeepCopy() *CompactArray
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CompactArray.
func (*CompactArray) DeepCopyInto ¶
func (a *CompactArray) DeepCopyInto(out *CompactArray)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*CompactArray) GetItem ¶
func (a *CompactArray) GetItem(index int) Item
Gets Item at provided index.
func (CompactArray) GetItems ¶
func (a CompactArray) GetItems() []Item
Gets all items stored in the array. The size of the returned array matches the ItemsCount it was initialized with.
func (*CompactArray) SetItem ¶
func (a *CompactArray) SetItem(index int, value Item)
Sets item at index to provided value.
func (CompactArray) String ¶
func (a CompactArray) String() string
Gets a string representation of the array contents. This is a relatively expensive operation.