Documentation
¶
Index ¶
- Constants
- Variables
- type BitArray
- func (ba *BitArray) Add(u uint) int
- func (ba *BitArray) AddBit(u uint) int
- func (ba *BitArray) AddN(u uint, width int) int
- func (ba *BitArray) Append(others ...BitArray)
- func (ba BitArray) Bytes() []byte
- func (ba BitArray) Len() int64
- func (ba *BitArray) Pack(fields ...interface{}) error
- func (ba *BitArray) Pad(n uint) int
- func (ba *BitArray) ReadUint(start, length int64) (uint, error)
- func (ba *BitArray) Set(n int64)
- func (ba *BitArray) ShiftL(n int64)
- func (ba *BitArray) Slice(startBit, length int64) (*BitArray, error)
- func (ba BitArray) String() string
- func (ba BitArray) Test(i int64) bool
- func (ba *BitArray) Unset(n int64)
- type Option
- type Reader
Constants ¶
const ( // SeekStart seeks relative to the origin of the file SeekStart = 0 // SeekCurrent seeks relative to the current offset SeekCurrent = 1 // SeekEnd seeks relative to the end SeekEnd = 2 )
Variables ¶
var ( // EOF is returned when no more input is available. EOF = errors.New("EOF") // revive:disable:error-naming // ErrInvalidWhence is return for invalid seeking. ErrInvalidWhence = errors.New("invalid whence") // ErrInvalidOffset is returned for invalid seek offsets. ErrInvalidOffset = errors.New("invalid offset") )
Functions ¶
This section is empty.
Types ¶
type BitArray ¶
type BitArray struct {
// contains filtered or unexported fields
}
BitArray holds an array of bits.
func NewFromBytes ¶
NewFromBytes creates a BitArray from the given []byte and count bits. Count is from position 0 of b.
func Pack ¶
Pack stuff together into a BitArray.
func (*BitArray) Add ¶
Add an uint to the array with leading zeros removed, returns the number of bits added.
func (*BitArray) AddBit ¶
AddBit adds a single bit to the array.
func (*BitArray) AddN ¶
AddN adds a uint with a fixed width of n, left padded to width with zeros, returns the number of bits added.
func (*BitArray) Append ¶
Append packs another BitArray on the end.
func (*BitArray) Pack ¶
Pack stuff together into existing array.
func (*BitArray) ReadUint ¶
ReadUint reads a uint from the BitArray.
func (*BitArray) ShiftL ¶
ShiftL returns a new BitArray with all bits to the left n times.
func (*BitArray) Slice ¶
Slice reads a range from the BitArray.
func (BitArray) String ¶
Bytes returns the BitArray as bytes. The remaining bits of the last byte are set to zero.
func (BitArray) Test ¶
Test returns true if bit at (zero based) offset i is 1, false otherwise.
type Option ¶ added in v0.7.0
type Option option
func SetBytes ¶ added in v0.7.0
SetBytes configures the BitArray with initial data.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
A Reader implements the BitReader interface.
func (*Reader) ReadBit ¶
ReadBit advances one bit and returns the result of a boolean AND test on it.
func (*Reader) ReadBits ¶
ReadBits reads n bits from the BitArray into out.