|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Classes | |
| struct | Display_Node |
| One node of a reconstructed display tree. More... | |
| struct | Frame |
| One verified encoding event, plus the tree after the event. More... | |
| struct | Snapshot |
| A complete tree for one externally observable encoder state. More... | |
Functions | |
| std::string | byte_label (const unsigned char byte) |
| Return an unambiguous, terminal-safe label for a byte. | |
| std::string | next_code (const Aleph::Adaptive_Huffman_Encoder &encoder, const unsigned char byte) |
| Probe a byte's code without changing the source encoder. | |
| void | insert_code (Snapshot &tree, const std::string &code, const int symbol, const std::uint64_t weight) |
| Insert a code into the display trie and accumulate its frequency. | |
| void | position_nodes (Snapshot &tree, const int node, const size_t depth, size_t &next_leaf) |
| Assign inorder leaf positions and center parents over children. | |
| Snapshot | snapshot (const Aleph::Adaptive_Huffman_Encoder &encoder) |
| Reconstruct and validate the tree using public encoder operations. | |
| Aleph::Array< Frame > | trace (const std::string_view input) |
| Record an actual online round trip, starting with the empty model. | |
| void | print_tree (std::ostream &out, const Snapshot &tree, const int node=0, const std::string &indent=" ", const std::string &edge="") |
| Print a byte-labelled, edge-labelled tree using portable ASCII. | |
|
inline |
Return an unambiguous, terminal-safe label for a byte.
| byte | Byte to describe. |
Definition at line 51 of file adaptive_huffman_demo_support.H.
References Aleph::and, and byte_label().
Referenced by byte_label(), and print_tree().
|
inline |
Insert a code into the display trie and accumulate its frequency.
| tree | Destination display tree. |
| code | Actual root-to-leaf code. |
| symbol | Byte value or -1 for NYT. |
| weight | Current symbol frequency. |
Definition at line 110 of file adaptive_huffman_demo_support.H.
References adaptive_huffman_demo::Display_Node::code, Aleph::code(), and adaptive_huffman_demo::Snapshot::nodes.
Referenced by snapshot().
|
inline |
Probe a byte's code without changing the source encoder.
| encoder | State immediately before the proposed byte. |
| byte | Byte to probe. |
Definition at line 76 of file adaptive_huffman_demo_support.H.
References Aleph::bits(), and Aleph::copy().
Referenced by snapshot().
|
inline |
Assign inorder leaf positions and center parents over children.
| tree | Tree to lay out. |
| node | Current node index. |
| depth | Current depth below the root. |
| next_leaf | Counter of already positioned leaves. |
Definition at line 139 of file adaptive_huffman_demo_support.H.
References adaptive_huffman_demo::Snapshot::depth, adaptive_huffman_demo::Snapshot::nodes, and position_nodes().
Referenced by position_nodes(), and snapshot().
|
inline |
Print a byte-labelled, edge-labelled tree using portable ASCII.
| out | Destination stream. |
| tree | Snapshot to render. |
| node | Current node index. |
| indent | Ancestor branch prefix. |
| edge | Empty at the root, otherwise the incoming edge decoration. |
Definition at line 276 of file adaptive_huffman_demo_support.H.
References byte_label(), adaptive_huffman_demo::Snapshot::nodes, out, and print_tree().
Referenced by print_tree().
|
inline |
Reconstruct and validate the tree using public encoder operations.
| encoder | Source encoder; it is never modified. |
| std::logic_error | if the public codes do not form a full tree. |
Definition at line 162 of file adaptive_huffman_demo_support.H.
References ah_logic_error_if, ah_logic_error_unless, Aleph::and, Aleph::code(), Aleph::count(), Aleph::Adaptive_Huffman_Encoder::frequency(), insert_code(), adaptive_huffman_demo::Snapshot::leaf_count, next_code(), adaptive_huffman_demo::Snapshot::nodes, position_nodes(), Aleph::Adaptive_Huffman_Encoder::symbols_processed(), and value.
Referenced by trace().
|
inline |
Record an actual online round trip, starting with the empty model.
| input | Bytes to illustrate. |
| std::logic_error | if the decoder disagrees at any symbol boundary. |
Definition at line 231 of file adaptive_huffman_demo_support.H.
References ah_logic_error_if, Aleph::Array< T >::append(), Aleph::bits(), adaptive_huffman_demo::Frame::byte, Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Encoder::encode(), Aleph::Adaptive_Huffman_Decoder::finish(), adaptive_huffman_demo::Frame::first_appearance, Aleph::Adaptive_Huffman_Encoder::frequency(), adaptive_huffman_demo::Frame::literal, adaptive_huffman_demo::Frame::path, snapshot(), adaptive_huffman_demo::Frame::total_bits, and adaptive_huffman_demo::Frame::tree.