huffman

package
v0.0.0-...-9bd9f91 Latest Latest
Warning

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

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

Documentation

Overview

Package huffman provices some implementations of different algorithms for generating Huffman trees.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode

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

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

func GenerateCodeForIAA

func GenerateCodeForIAA(lens []int32, reuseCache []int32)

GenerateCodeForIAA generate code in non-reversed format. Result will be inplace.

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 []int32, codeLens []int32) 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 []int32)

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 []int32, codeLens []int32) (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