huffman
Functions
-
int main(int argc, char *argv[])
huffman [ option ] [ infile ]
-s int
start index \((S)\)
-L str
output filename of double-type average code length
infile str
double-type probability sequence
stdout
ascii-type codebook
- Parameters:
argc – [in] Number of arguments.
argv – [in] Argument vector.
- Returns:
0 on success, 1 on failure.
See also
-
class HuffmanCoding
Generate variable-length code codewords based on Huffman coding.
The input is the probabilites or frequencies of \(N\) events:
\[ \begin{array}{cccc} p(0), & p(1), & \ldots, & p(N-1), \end{array} \]and the output is the corresponding codewords:\[ \begin{array}{cccc} c(0), & c(1), & \ldots, & c(N-1), \end{array} \]where \(c(n) \in \{0,1\}^{\ast}\).The implementation is based on priority queue.
Public Functions
-
explicit HuffmanCoding(int num_element)
- Parameters:
num_element – [in] Number of elements.
-
inline int GetNumElement() const
- Returns:
Number of elements.
-
inline bool IsValid() const
- Returns:
True if this object is valid.
-
bool Run(const std::vector<double> &probabilities, std::vector<std::string> *codewords) const
- Parameters:
probabilities – [in] \(N\) probabilities or frequencies.
codewords – [out] \(N\) codewords.
-
explicit HuffmanCoding(int num_element)