huffman

package
v0.0.0-...-849f07b Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCodeBook

func BuildCodeBook(tree NodesHeap) map[rune]int

func CountChars

func CountChars(f *os.File) map[rune]int

Types

type Node

type Node struct {
	Parent *Node
	Left   *Node
	Right  *Node
	Freq   uint64
	Char   rune
	Which  bool // true if left, false if right
}

func NewNode

func NewNode(char rune, freq uint64) Node

type NodesHeap

type NodesHeap []*Node

func BuildHuffmanTree

func BuildHuffmanTree(nodes NodesHeap) NodesHeap

func PrepareLeafNodes

func PrepareLeafNodes(charCounts map[rune]int) NodesHeap

func (NodesHeap) Len

func (h NodesHeap) Len() int

func (NodesHeap) Less

func (h NodesHeap) Less(i, j int) bool

func (*NodesHeap) Pop

func (h *NodesHeap) Pop() interface{}

func (*NodesHeap) Push

func (h *NodesHeap) Push(x interface{})

func (NodesHeap) Swap

func (h NodesHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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