1package helpers 2 3import "bytes" 4 5type BitSet struct { 6 entries []byte 7} 8 9func NewBitSet(bitCount uint) BitSet { 10 return BitSet{make([]byte, (bitCount+7)/8)} 11} 12 13func (bs BitSet) HasBit(bit uint) bool { 14 return (bs.entries[bit/8] & (1 << (bit & 7))) != 0 15} 16 17func (bs BitSet) SetBit(bit uint) { 18 bs.entries[bit/8] |= 1 << (bit & 7) 19} 20 21func (bs BitSet) Equals(other BitSet) bool { 22 return bytes.Equal(bs.entries, other.entries) 23} 24 25func (bs BitSet) String() string { 26 return string(bs.entries) 27} 28