Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Adaptive_Huffman.H File Reference

One-pass adaptive Huffman coding of bytes using FGK updates. More...

#include <climits>
#include <cstddef>
#include <cstdint>
#include <limits>
#include <string>
#include <string_view>
#include <ah-errors.H>
#include <bitArray.H>
Include dependency graph for Adaptive_Huffman.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::adaptive_huffman_detail::Model
 
struct  Aleph::adaptive_huffman_detail::Model::Node
 
class  Aleph::Adaptive_Huffman_Encoder
 Stateful, one-pass FGK Huffman encoder for binary byte strings. More...
 
class  Aleph::Adaptive_Huffman_Decoder
 Incremental FGK decoder accepting arbitrarily fragmented bits. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::adaptive_huffman_detail
 

Detailed Description

One-pass adaptive Huffman coding of bytes using FGK updates.

Encoder and decoder start with a single NYT (not yet transmitted) leaf. An unseen byte is represented by the current NYT path followed by its eight bits, most significant bit first. A known byte uses its current leaf path. Left edges are 0 and right edges are 1. Both sides update the tree after each complete byte using the Faller-Gallager-Knuth rule. The NYT leaf is retained even after all 256 bytes have appeared.

There is no tree header, end marker, padding, or checksum. The caller must preserve the exact bit count (for example with BitArray::save()/load()) or frame the transmission separately. finish() detects a partial final codeword; it cannot detect missing complete codewords or arbitrary bit corruption. This format is independent of the static codec in Huffman.H.

See also
Adaptive_Huffman_Encoder
Adaptive_Huffman_Decoder
https://www.ittc.ku.edu/~jsv/Papers/Vit87.jacmACMversion.pdf J. S. Vitter, Design and Analysis of Dynamic Huffman Codes (1987), Section 2 (Algorithm FGK).

Definition in file Adaptive_Huffman.H.