github.com/evanw/esbuild@v0.21.4/internal/helpers/bitset.go (about)

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