huffman

package
v0.0.0-...-63270c8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintTree

func PrintTree(node *Node, side string)

Types

type Node

type Node struct {
	LeftLeaf  *Node
	RightLeaf *Node
	// contains filtered or unexported fields
}

func GetLeafByCode

func GetLeafByCode(node *Node, code []byte, bit int) *Node

func NewNode

func NewNode(isLeaf bool, weight int, char rune) *Node

func (*Node) Char

func (n *Node) Char() rune

func (*Node) GetNodeByCode

func (n *Node) GetNodeByCode(code []byte) *Node

func (*Node) IsLeaf

func (n *Node) IsLeaf() bool

func (*Node) SetWeight

func (n *Node) SetWeight(w int)

func (*Node) String

func (n *Node) String() string

func (*Node) Weight

func (n *Node) Weight() int

type Sorter

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

func NewSorter

func NewSorter() *Sorter

func (*Sorter) AddNode

func (s *Sorter) AddNode(node *Node)

func (*Sorter) GetFirst

func (s *Sorter) GetFirst() *Node

func (*Sorter) Len

func (s *Sorter) Len() int

func (*Sorter) Less

func (s *Sorter) Less(i, j int) bool

func (*Sorter) Parse

func (s *Sorter) Parse(input string)

func (*Sorter) Print

func (s *Sorter) Print()

func (*Sorter) String

func (s *Sorter) String() string

func (*Sorter) Swap

func (s *Sorter) Swap(i, j int)

type Tree

type Tree struct {
	Root *Node
	// contains filtered or unexported fields
}

func NewTree

func NewTree(nodes *Sorter) *Tree

func (*Tree) BuildTree

func (t *Tree) BuildTree()

func (*Tree) Count

func (t *Tree) Count() int

func (*Tree) GetTable

func (t *Tree) GetTable() map[rune][]int

func (*Tree) PrintTreeByLevel

func (t *Tree) PrintTreeByLevel()

Jump to

Keyboard shortcuts

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