MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / HuffEncode

Function HuffEncode

compression/huffmancoding.go:95–101  ·  view source on GitHub ↗

HuffEncode encodes the string in by applying the mapping defined by codes.

(codes map[rune][]bool, in string)

Source from the content-addressed store, hash-verified

93
94// HuffEncode encodes the string in by applying the mapping defined by codes.
95func HuffEncode(codes map[rune][]bool, in string) []bool {
96 out := make([]bool, 0)
97 for _, s := range in {
98 out = append(out, codes[s]...)
99 }
100 return out
101}
102
103// HuffDecode recursively decodes the binary code in, by traversing the Huffman compression tree pointed by root.
104// current stores the current node of the traversing algorithm.

Callers 1

TestHuffmanFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestHuffmanFunction · 0.74