Documentation ¶
Index ¶
- func Decode(inputFileName, outputFileName string, e *Encoder)
- func Encode(inputFileName, compressedFileName string, e *Encoder)
- func GetCompressionRatio(originalFileName, compressedFileName string) (float64, error)
- type BitReader
- type BitWriter
- type Encoder
- type HTWrapper
- type HuffNode
- type HuffTree
- type PriorityQueue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode(): Takes an encoded .huff file, decodes and writes decoded text to
* an output file.
func GetCompressionRatio ¶
GetCompressionRatio(): Compares the sizes of the original and the compressed
* files, returns the ratio as a float64.
Types ¶
type BitReader ¶
type BitReader struct {
// contains filtered or unexported fields
}
func NewBitReader ¶
type BitWriter ¶
type BitWriter struct {
// contains filtered or unexported fields
}
func NewBitWriter ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func (*Encoder) DecodeToDefaultOutputFile ¶
DecodeToDefaultOutputFile():
* Wrapper function for Decode(). Allows for decoding without specifying an * output file. Creates an output file based on the name for the input file.
func (*Encoder) EncodeToDefaultOutputFile ¶
EncodeToDefaultOutputFile():
* Wrapper for Encode() so an output file name doesn't need to be specified. * Creates an output file name based on the input file name.
type HuffTree ¶
type HuffTree struct {
// contains filtered or unexported fields
}
func (*HuffTree) CodeMap ¶
Returns a map of the unique codes which each character will be represented by in a particular encoding.
func (*HuffTree) Combine ¶
Returns a new HuffTree with a new root node pointing at the two which were combined. The left child has lower frequency, and the freq value of the root node is the sum of its children.
func (*HuffTree) MakeHuffmanTree ¶
type PriorityQueue ¶
type PriorityQueue []*HTWrapper
PriorityQueue implemented using Heap interface in order to always be able to access the two trees with the lowest total frequencies of their leaves
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) Print ¶
func (pq *PriorityQueue) Print()
Prints an array representation of the priority queue's contents
func (*PriorityQueue) Println ¶
func (pq *PriorityQueue) Println()
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(x any)
func (PriorityQueue) Swap ¶
func (pq PriorityQueue) Swap(i, j int)