golomb

package
v0.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidGolombK is returned when the Golomb parameter k is invalid.
	ErrInvalidGolombK = errors.New("invalid golomb parameter k")
	// ErrInvalidEncodingParams is returned when encoding parameters are invalid.
	ErrInvalidEncodingParams = errors.New("invalid encoding parameters")
)

Functions

This section is empty.

Types

type BitReader

type BitReader struct {
	// contains filtered or unexported fields
}

BitReader reads bits from an io.ByteReader.

func NewBitReader

func NewBitReader(r io.ByteReader) *BitReader

NewBitReader creates a new BitReader on top of an io.ByteReader.

func (*BitReader) ReadBigIntBits

func (br *BitReader) ReadBigIntBits(n int) (*big.Int, error)

ReadBigIntBits reads n bits and returns them as a big.Int.

func (*BitReader) ReadBit

func (br *BitReader) ReadBit() (bool, error)

ReadBit reads a single bit.

func (*BitReader) ReadBits

func (br *BitReader) ReadBits(n int) (uint64, error)

ReadBits reads n bits and returns them as a uint64.

type BitWriter

type BitWriter struct {
	// contains filtered or unexported fields
}

BitWriter writes bits to an io.Writer.

func NewBitWriter

func NewBitWriter(w io.ByteWriter) *BitWriter

NewBitWriter creates a new BitWriter on top of an io.Writer. The underlying writer must support WriteByte (e.g., bufio.Writer).

func (*BitWriter) Flush

func (bw *BitWriter) Flush() error

Flush writes any pending bits to the underlying writer, padded with zeros.

func (*BitWriter) WriteBigIntBits

func (bw *BitWriter) WriteBigIntBits(val *big.Int, n int) error

WriteBigIntBits writes the n least significant bits of val, most significant first.

func (*BitWriter) WriteBit

func (bw *BitWriter) WriteBit(bit bool) error

WriteBit writes a single bit (0 or 1).

func (*BitWriter) WriteBits

func (bw *BitWriter) WriteBits(val uint64, n int) error

WriteBits writes the n least significant bits of val, most significant first.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decodes integers using Golomb-Rice coding.

func NewDecoder

func NewDecoder(r io.ByteReader, k int) *Decoder

NewDecoder creates a new decoder.

func (*Decoder) Decode

func (gd *Decoder) Decode() (uint64, error)

Decode decodes a value.

func (*Decoder) DecodeBig

func (gd *Decoder) DecodeBig() (*big.Int, error)

DecodeBig decodes a value as big.Int.

type Encoder

type Encoder struct {
	BitWriter *BitWriter
	// contains filtered or unexported fields
}

Encoder encodes integers using Golomb-Rice coding.

func NewEncoder

func NewEncoder(w io.Writer, k int) (*Encoder, error)

NewEncoder creates a new encoder.

func (*Encoder) Encode

func (ge *Encoder) Encode(d uint64) error

Encode encodes a value d.

func (*Encoder) EncodeBig

func (ge *Encoder) EncodeBig(d *big.Int) error

EncodeBig encodes a big.Int delta.

func (*Encoder) Flush

func (ge *Encoder) Flush() error

Flush flushes the underlying bit writer and any buffered writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL