github.com/scottcagno/storage@v1.8.0/pkg/bits/binrecord.go (about)

     1  package bits
     2  
     3  type BinaryRecord struct {
     4  	data []byte
     5  }
     6  
     7  func NewBinaryRecord(hint uint) *BinaryRecord {
     8  	br := &BinaryRecord{
     9  		data: nil,
    10  	}
    11  	checkResize(&br.data, hint)
    12  	return br
    13  }
    14  
    15  func (br *BinaryRecord) Resize(i uint) {
    16  	checkResize(&br.data, i)
    17  }
    18  
    19  func (br *BinaryRecord) Set(i uint) {
    20  	RawBytesSetBit(&br.data, i)
    21  }
    22  
    23  func (br *BinaryRecord) Unset(i uint) {
    24  	RawBytesUnsetBit(&br.data, i)
    25  }
    26  
    27  func (br *BinaryRecord) IsSet(i uint) bool {
    28  	return RawBytesHasBit(&br.data, i)
    29  }
    30  
    31  func (br *BinaryRecord) Get(i uint) uint {
    32  	return RawBytesGetBit(&br.data, i)
    33  }
    34  
    35  func (br *BinaryRecord) Len() uint {
    36  	return uint(len(br.data) * 8)
    37  }
    38  
    39  func (br *BinaryRecord) String() string {
    40  	return RawBytesStringer(&br.data)
    41  }