RedHuffman:
Filter:
redSys/Classes (extension) | Red > redTools

RedHuffman
ExtensionExtension

huffman coding

Description

The principle is "to use fewer bits for more frequently occurring character".

See http://www.cs.duke.edu/csed/poop/huff/info/

NOTE: Works with Integer, Float and Symbol. Can also take a String instead of an Array.

Class Methods

.compress

Compresses an array into a string of binary numbers. Creates a *tree and a *dict as well.

.decompress

Decompresses a binary string into an array. Make sure you use the right *tree and *dict as generated by the compress method.

.binaryStringToBytes

Converts a binary string into 8-bit bytes. Up to 7 zeros might be padded automatically at the end. The number of zeros is stored in *pad. *pad is semi-private and used when converting back to bytes.

.bytesToBinaryString

Converts an array of 8-bit bytes into a binary string.

.pad

Semi-private counter for number of padded zeros. Set by *binaryStringToBytes and read by *bytesToBinaryString.

.tree

Multi-level List with values as leaves.

.dict

Look-up dictionary with values and binary strings.

Examples