Documentation ¶
Index ¶
Constants ¶
const EndOfHeaderLength = ":"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compressor ¶
type Compressor struct {
// contains filtered or unexported fields
}
func NewCompressor ¶
func NewCompressor(inputFile, outputFile string) *Compressor
func (*Compressor) Compress ¶
func (c *Compressor) Compress() error
type Decompressor ¶
type Decompressor struct {
// contains filtered or unexported fields
}
func NewDecompressor ¶
func NewDecompressor(inputFile, outputFile string) *Decompressor
func (*Decompressor) Decompress ¶
func (d *Decompressor) Decompress() error
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func FromHeader ¶
FromHeader deserializes the header string in a Huffman tree.
func NewHuffmanTree ¶
NewHuffmanTree builds a HuffmanTree based on the order of weights from the priority queue (ref: https://opendsa-server.cs.vt.edu/ODSA/Books/CS3/html/Huffman.html).
func (*Node) ToHeader ¶
ToHeader serializes the tree in a string format using pre-order traversal. The Node's weight is not necessary for either compression and decompression.
func (*Node) ToLookup ¶
ToLookup assigns the Huffman Code path on the tree to each rune to generate a lookup map, ex: The tree below (using chars instead of runes to simplify the example):
3 0 1 A 8 0 1 C D
Becomes: {A: 0, C: 10, B: 11}
func (*Node) ToReverseLookup ¶
ToReverseLookup assigns runes to Huffman Code paths to generate a reverse lookup map.
type PriorityQueue ¶
type PriorityQueue []Weighter
func NewPriorityQueue ¶
func NewPriorityQueue(runeFrequency map[rune]int) *PriorityQueue
NewPriorityQueue returns a PriorityQueue of Nodes with min heap property based on runeFrequency map.
func (PriorityQueue) Len ¶
func (pq PriorityQueue) Len() int
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(i, j int) bool
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() any
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(item any)
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)