arithmetic

package
v0.0.0-...-5787e7a Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ByteSize = 8

ByteSize is the size of a byte in bits (typically 8)

Variables

This section is empty.

Functions

func Compress

func Compress(input []byte) []byte

Compress takes a slice of bytes and returns a slice of bytes representing the compressed stream

func Decompress

func Decompress(input []byte) []byte

Decompress takes a slice of bytes and returns a slice of bytes representing the decompressed stream

func NewReader

func NewReader(r io.Reader) io.Reader

NewReader creates an io.Reader object with an io.Reader

func NewWriter

func NewWriter(w io.Writer) io.WriteCloser

NewWriter creates an io.WriteCloser object with an io.Writer

Types

type BitSlice

type BitSlice []bool

BitSlice represents a slice of bits (represented as bools)

func FromByteSlice

func FromByteSlice(bytes []byte) BitSlice

func GetNextBit

func GetNextBit(bits BitSlice) (uint32, BitSlice)

GetNextBit returns the next bit and a new bit slice with the first bit popped off. If there are no more bits, then the function returns 0.

func PushBits

func PushBits(bits BitSlice, bit bool, pendingBits int) BitSlice

PushBits takes a BitSlice, a bit, and the number of pendingBits. PushBits returns the BitSlice with the bit and pendingBits pushed.

func PushBitsPending

func PushBitsPending(pendingBits int, bit bool) BitSlice

func (BitSlice) AsByteSlice

func (bits BitSlice) AsByteSlice() (error, []byte)

func (BitSlice) Pack

func (bits BitSlice) Pack() BitSlice

Pack packs a BitSlice to fit within 8 bit bytes

func (BitSlice) Unpack

func (bits BitSlice) Unpack() BitSlice

Unpack unpacks a BitSlice from it's byte representation into the original BitSlice

type Model

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

Model represents frequency tables for characters in a byte

type Reader

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

Reader takes an io.Reader to read from when decompressing

func (*Reader) Close

func (r *Reader) Close() error

Close only exists to satisfy the io.WriteCloser interface

func (*Reader) Read

func (r *Reader) Read(content []byte) (n int, err error)

type Writer

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

Writer takes an io.Writer to write to when compressing

func (*Writer) Close

func (writer *Writer) Close() error

Close only exists to satisfy the io.WriteCloser interface

func (*Writer) Write

func (writer *Writer) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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