Documentation
¶
Overview ¶
Package bitutil provides bit manipulation utilities for barcode processing.
Index ¶
- type BitArray
- func (ba *BitArray) AppendBit(bit bool)
- func (ba *BitArray) AppendBitArray(other *BitArray)
- func (ba *BitArray) AppendBits(value uint32, numBits int)
- func (ba *BitArray) BitData() []uint32
- func (ba *BitArray) Clear()
- func (ba *BitArray) Clone() *BitArray
- func (ba *BitArray) Flip(i int)
- func (ba *BitArray) Get(i int) bool
- func (ba *BitArray) GetNextSet(from int) int
- func (ba *BitArray) GetNextUnset(from int) int
- func (ba *BitArray) IsRange(start, end int, value bool) bool
- func (ba *BitArray) Reverse()
- func (ba *BitArray) Set(i int)
- func (ba *BitArray) SetBulk(i int, newBits uint32)
- func (ba *BitArray) SetRange(start, end int)
- func (ba *BitArray) Size() int
- func (ba *BitArray) SizeInBytes() int
- func (ba *BitArray) String() string
- func (ba *BitArray) ToBytes(bitOffset int, array []byte, offset, numBytes int)
- func (ba *BitArray) Xor(other *BitArray)
- type BitMatrix
- func (bm *BitMatrix) BottomRightOnBit() []int
- func (bm *BitMatrix) Clear()
- func (bm *BitMatrix) Clone() *BitMatrix
- func (bm *BitMatrix) EnclosingRectangle() []int
- func (bm *BitMatrix) Equals(other *BitMatrix) bool
- func (bm *BitMatrix) Flip(x, y int)
- func (bm *BitMatrix) FlipAll()
- func (bm *BitMatrix) Get(x, y int) bool
- func (bm *BitMatrix) Height() int
- func (bm *BitMatrix) Rotate(degrees int)
- func (bm *BitMatrix) Rotate90()
- func (bm *BitMatrix) Rotate180()
- func (bm *BitMatrix) Row(y int, row *BitArray) *BitArray
- func (bm *BitMatrix) RowSize() int
- func (bm *BitMatrix) Set(x, y int)
- func (bm *BitMatrix) SetRegion(left, top, width, height int)
- func (bm *BitMatrix) SetRow(y int, row *BitArray)
- func (bm *BitMatrix) String() string
- func (bm *BitMatrix) StringWithChars(setString, unsetString string) string
- func (bm *BitMatrix) TopLeftOnBit() []int
- func (bm *BitMatrix) Unset(x, y int)
- func (bm *BitMatrix) Width() int
- func (bm *BitMatrix) Xor(mask *BitMatrix)
- type BitSource
- type BitSourceError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BitArray ¶
type BitArray struct {
// contains filtered or unexported fields
}
BitArray is a simple, fast array of bits represented compactly by an array of uint32 values internally.
func NewBitArray ¶
NewBitArray creates a new BitArray with the given size.
func NewBitArrayFromBits ¶
NewBitArrayFromBits creates a BitArray from existing data (for testing).
func (*BitArray) AppendBitArray ¶
AppendBitArray appends another BitArray to this one.
func (*BitArray) AppendBits ¶
AppendBits appends the least-significant numBits bits of value, from most significant to least significant.
func (*BitArray) GetNextSet ¶
GetNextSet returns the index of the first set bit starting from the given index, or size if none are set.
func (*BitArray) GetNextUnset ¶
GetNextUnset returns the index of the first unset bit starting from the given index, or size if none are unset.
func (*BitArray) SizeInBytes ¶
SizeInBytes returns the number of bytes needed to hold the bits.
func (*BitArray) String ¶
String returns a string representation using 'X' for set and '.' for unset.
type BitMatrix ¶
type BitMatrix struct {
// contains filtered or unexported fields
}
BitMatrix represents a 2D matrix of bits. x is the column position, y is the row position. The origin is at the top-left.
func NewBitMatrix ¶
NewBitMatrix creates a new square BitMatrix with the given dimension.
func NewBitMatrixWithSize ¶
NewBitMatrixWithSize creates a new BitMatrix with the given width and height.
func ParseBoolMatrix ¶
ParseBoolMatrix creates a BitMatrix from a 2D boolean array.
func ParseStringMatrix ¶
ParseStringMatrix creates a BitMatrix from a string representation.
func (*BitMatrix) BottomRightOnBit ¶
BottomRightOnBit returns the [x, y] of the bottom-right set bit, or nil if none are set.
func (*BitMatrix) EnclosingRectangle ¶
EnclosingRectangle returns [left, top, width, height] of the enclosing rectangle of all set bits, or nil if all bits are unset.
func (*BitMatrix) Rotate90 ¶
func (bm *BitMatrix) Rotate90()
Rotate90 rotates the matrix 90 degrees counterclockwise.
func (*BitMatrix) Rotate180 ¶
func (bm *BitMatrix) Rotate180()
Rotate180 rotates the matrix 180 degrees.
func (*BitMatrix) Row ¶
Row returns a row as a BitArray. If row is nil or too small, a new one is allocated.
func (*BitMatrix) String ¶
String returns a string representation using "X " for set and " " for unset.
func (*BitMatrix) StringWithChars ¶
StringWithChars returns a string representation using the given set/unset strings.
func (*BitMatrix) TopLeftOnBit ¶
TopLeftOnBit returns the [x, y] of the top-left set bit, or nil if none are set.
type BitSource ¶
type BitSource struct {
// contains filtered or unexported fields
}
BitSource reads bits from a byte sequence where the number of bits read is not necessarily a multiple of 8.
func NewBitSource ¶
NewBitSource creates a new BitSource from a byte slice. Bits are read from the first byte first, from most-significant to least-significant.
func (*BitSource) ByteOffset ¶
ByteOffset returns the index of the next byte to be read.
type BitSourceError ¶
type BitSourceError struct {
NumBits int
}
BitSourceError is returned when an invalid number of bits is requested.
func (*BitSourceError) Error ¶
func (e *BitSourceError) Error() string