huffman

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode

func GenerateCode(reuseCache []uint32, maxLen int, lens []uint32, rcodes []uint16)

GenerateCode generate code in reversed format. This method can be used for deflate header written

func GenerateCode2

func GenerateCode2(lens []uint32)

GenerateCode2 generate code in reversed format. Result will be inplace. reuseCache should be

Types

type LenLimitedCode

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

LenLimitedCode implements a code length limited algorithm huffman tree generator.

func NewLenLimitedCode

func NewLenLimitedCode() *LenLimitedCode

NewLenLimitedCode creates a new LenLimitedCode instance

func (*LenLimitedCode) Generate

func (l *LenLimitedCode) Generate(limitedLen int, histogram []uint32, codeLens []uint32) int

Generate huffman tree from histogram and write tree codes into codes.

type MoffatHuffmanCode

type MoffatHuffmanCode struct{}

MoffatHuffmanCode implements In-Place Calculation of Minimum-Redundancy Codes. Check http://hjemmesider.diku.dk/~jyrki/Paper/WADS95.pdf .

func (*MoffatHuffmanCode) Generate

func (m *MoffatHuffmanCode) Generate(histogram []uint32)

Generate huffman tree from histogram and write tree codes into codes.

type TreeGenerator

type TreeGenerator interface {
	// Generate huffman tree from histogram and write tree codes into codes.
	Generate(maxLens int, histogram []uint32, codeLens []uint32) (num int)
}

TreeGenerator generate code's lengths from the histogram A huffman tree generator must be reused due to memory allocation overhead.

Jump to

Keyboard shortcuts

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