Documentation ¶
Index ¶
- Variables
- func Arch() int
- func Base64StdEncoding()
- func Cap() uint
- func Get(m []byte, i int) bool
- func GetBit(b byte, i int) bool
- func Len(m []byte) int
- func LittleEndian()
- func NewSlice(l int) []byte
- func Set(m []byte, i int, v bool)
- func SetBit(b byte, i int, v bool) byte
- func SetBitRef(b *byte, i int, v bool)
- type BitSet
- func (b *BitSet) BinaryStorageSize() int
- func (b *BitSet) Bytes() []uint
- func (b *BitSet) Cap() uint
- func (b *BitSet) Compact() *BitSet
- func (b *BitSet) Count() uint
- func (b *BitSet) Equal(c *BitSet) bool
- func (b *BitSet) Flip(i uint) *BitSet
- func (b *BitSet) Has(i uint) bool
- func (b *BitSet) InPlaceUnion(compare *BitSet)
- func (b *BitSet) Len() uint
- func (b *BitSet) MarshalBinary() ([]byte, error)
- func (b *BitSet) MarshalJSON() ([]byte, error)
- func (b *BitSet) ReadFrom(stream io.Reader) (int64, error)
- func (b *BitSet) Set(i uint) *BitSet
- func (b *BitSet) SetAll() *BitSet
- func (b *BitSet) SetTo(i uint, value bool) *BitSet
- func (b *BitSet) Shrink(lastbitindex uint) *BitSet
- func (b *BitSet) String() string
- func (b *BitSet) UnmarshalBinary(data []byte) error
- func (b *BitSet) UnmarshalJSON(data []byte) error
- func (b *BitSet) Unset(i uint) *BitSet
- func (b *BitSet) UnsetAll() *BitSet
- func (b *BitSet) WriteTo(stream io.Writer) (int64, error)
- type BitVec
- type Bitmap
Constants ¶
This section is empty.
Variables ¶
var SZ = 1
var WS = Arch()
this is the word size of an int(32) in bits. an int(32) requires a min- imum of 4 bytes, each of which are made up of 8 bits, therefore 4x8=32 this same notion applies for int(64) such that 8 bytes * 8 bits/byte = 64
Functions ¶
func Base64StdEncoding ¶
func Base64StdEncoding()
Base64StdEncoding Marshal/Unmarshal BitSet with base64.StdEncoding(Default: base64.URLEncoding)
func Len ¶
Len returns the length (in bits) of the provided byteslice. It will always be a multipile of 8 bits.
func LittleEndian ¶
func LittleEndian()
LittleEndian Marshal/Unmarshal Binary as Little Endian(Default: binary.BigEndian)
func NewSlice ¶
NewSlice creates a new byteslice with length l (in bits). The actual size in bits might be up to 7 bits larger because they are stored in a byteslice.
Types ¶
type BitSet ¶
type BitSet struct {
// contains filtered or unexported fields
}
A BitSet is a set of bits. The zero value of a BitSet is an empty set of length 0.
func (*BitSet) BinaryStorageSize ¶
BinaryStorageSize returns the binary storage requirements
func (*BitSet) Compact ¶
Compact shrinks BitSet to so that we preserve all set bits, while minimizing memory usage. Compact calls Shrink.
func (*BitSet) Equal ¶
Equal tests the equivalence of two BitSets. False if they are of different sizes, otherwise true only if all the same bits are set
func (*BitSet) Flip ¶
Flip bit at i. If i>= Cap(), this function will panic. Warning: using a very large value for 'i' may lead to a memory shortage and a panic: the caller is responsible for providing sensible parameters in line with their memory capacity.
func (*BitSet) InPlaceUnion ¶
InPlaceUnion creates the destructive union of base set and compare set. This is the BitSet equivalent of | (or).
func (*BitSet) Len ¶
Len returns the number of bits in the BitSet. Note the difference to method Count, see example.
func (*BitSet) MarshalBinary ¶
MarshalBinary encodes a BitSet into a binary form and returns the result.
func (*BitSet) MarshalJSON ¶
MarshalJSON marshals a BitSet as a JSON structure
func (*BitSet) Set ¶
Set bit i to 1, the capacity of the bitset is automatically increased accordingly. If i>= Cap(), this function will panic. Warning: using a very large value for 'i' may lead to a memory shortage and a panic: the caller is responsible for providing sensible parameters in line with their memory capacity.
func (*BitSet) SetTo ¶
SetTo sets bit i to value. If i>= Cap(), this function will panic. Warning: using a very large value for 'i' may lead to a memory shortage and a panic: the caller is responsible for providing sensible parameters in line with their memory capacity.
func (*BitSet) Shrink ¶
Shrink shrinks BitSet so that the provided value is the last possible set value. It clears all bits > the provided index and reduces the size and length of the set.
Note that the parameter value is not the new length in bits: it is the maximal value that can be stored in the bitset after the function call. The new length in bits is the parameter value + 1. Thus it is not possible to use this function to set the length to 0, the minimal value of the length after this function call is 1.
A new slice is allocated to store the new bits, so you may see an increase in memory usage until the GC runs. Normally this should not be a problem, but if you have an extremely large BitSet its important to understand that the old BitSet will remain in memory until the GC frees it.
func (*BitSet) UnmarshalBinary ¶
UnmarshalBinary decodes the binary form generated by MarshalBinary.
func (*BitSet) UnmarshalJSON ¶
UnmarshalJSON unmarshals a BitSet from JSON created using MarshalJSON
type Bitmap ¶
type Bitmap []byte
Bitmap is a byteslice with bitmap functions. Creating one form existing data is as simple as bitmap := Bitmap(data).