|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
#include <Adaptive_Huffman.H>
Classes | |
| struct | Node |
Public Member Functions | |
| Model () noexcept | |
| Construct the initial tree containing only NYT. | |
| void | reset () noexcept |
| Restore the initial tree in O(alphabet_size) time. | |
| void | check_capacity () const |
| Reject an update that would overflow the frequency counters. | |
| int | block_leader (const int node) const noexcept |
| Find the highest-order node of a node's weight block. | |
| void | swap_nodes (const int a, const int b) noexcept |
| Exchange two non-ancestor subtrees and their order numbers. | |
| void | update (const unsigned char symbol) noexcept |
| Insert an unseen byte or increment an existing byte's path. | |
Public Attributes | |
| Node | nodes [max_nodes] = {} |
| Stable node storage. | |
| int | by_order [max_nodes] = {} |
| Order-to-node index. | |
| int | leaves [alphabet_size] = {} |
| Byte-to-leaf index, or -1 if unseen. | |
| int | nyt = root |
| Current NYT node index. | |
| int | used = 1 |
| Number of active nodes. | |
| size_t | distinct = 0 |
| Number of bytes seen so far. | |
Static Public Attributes | |
| static constexpr int | alphabet_size = 256 |
| Number of possible bytes. | |
| static constexpr int | max_nodes = 2 * alphabet_size + 1 |
| Including NYT. | |
| static constexpr int | root = 0 |
| Stable root node index. | |
Definition at line 67 of file Adaptive_Huffman.H.
|
inlinenoexcept |
Construct the initial tree containing only NYT.
Definition at line 102 of file Adaptive_Huffman.H.
References reset().
|
inlinenoexcept |
Find the highest-order node of a node's weight block.
| node | Index of the current node. |
Definition at line 140 of file Adaptive_Huffman.H.
References by_order, Aleph::low(), max_nodes, nodes, Aleph::adaptive_huffman_detail::Model::Node::order, and Aleph::adaptive_huffman_detail::Model::Node::weight.
Referenced by update().
|
inline |
Reject an update that would overflow the frequency counters.
| std::overflow_error | if UINT64_MAX bytes were already processed. |
Definition at line 127 of file Adaptive_Huffman.H.
References ah_overflow_error_if, nodes, and root.
Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), and Aleph::Adaptive_Huffman_Encoder::encode().
|
inlinenoexcept |
Restore the initial tree in O(alphabet_size) time.
Definition at line 108 of file Adaptive_Huffman.H.
References by_order, distinct, leaves, max_nodes, nodes, nyt, Aleph::adaptive_huffman_detail::Model::Node::order, root, and used.
Referenced by Model(), Aleph::Adaptive_Huffman_Encoder::reset(), and Aleph::Adaptive_Huffman_Decoder::reset().
|
inlinenoexcept |
Exchange two non-ancestor subtrees and their order numbers.
| a | First node index (not the root). |
| b | Second node index (not the root or an ancestor of a). |
Definition at line 157 of file Adaptive_Huffman.H.
References by_order, Aleph::adaptive_huffman_detail::Model::Node::left, nodes, Aleph::adaptive_huffman_detail::Model::Node::order, Aleph::adaptive_huffman_detail::Model::Node::parent, and Aleph::adaptive_huffman_detail::Model::Node::right.
Referenced by update().
|
inlinenoexcept |
Insert an unseen byte or increment an existing byte's path.
| symbol | Byte just encoded or decoded. |
Definition at line 181 of file Adaptive_Huffman.H.
References Aleph::and, block_leader(), by_order, distinct, leaves, Aleph::adaptive_huffman_detail::Model::Node::left, nodes, nyt, Aleph::adaptive_huffman_detail::Model::Node::order, Aleph::adaptive_huffman_detail::Model::Node::parent, Aleph::adaptive_huffman_detail::Model::Node::right, swap_nodes(), Aleph::adaptive_huffman_detail::Model::Node::symbol, used, and Aleph::adaptive_huffman_detail::Model::Node::weight.
Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), and Aleph::Adaptive_Huffman_Encoder::encode().
|
staticconstexpr |
Number of possible bytes.
Definition at line 69 of file Adaptive_Huffman.H.
Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), and Aleph::Adaptive_Huffman_Encoder::encode().
| int Aleph::adaptive_huffman_detail::Model::by_order[max_nodes] = {} |
Order-to-node index.
Definition at line 95 of file Adaptive_Huffman.H.
Referenced by block_leader(), reset(), swap_nodes(), and update().
| size_t Aleph::adaptive_huffman_detail::Model::distinct = 0 |
Number of bytes seen so far.
Definition at line 99 of file Adaptive_Huffman.H.
Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Encoder::distinct_symbols(), Aleph::Adaptive_Huffman_Decoder::distinct_symbols(), reset(), and update().
| int Aleph::adaptive_huffman_detail::Model::leaves[alphabet_size] = {} |
Byte-to-leaf index, or -1 if unseen.
Definition at line 96 of file Adaptive_Huffman.H.
Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Encoder::encode(), Aleph::Adaptive_Huffman_Encoder::frequency(), Aleph::Adaptive_Huffman_Decoder::frequency(), reset(), and update().
|
staticconstexpr |
Including NYT.
Definition at line 70 of file Adaptive_Huffman.H.
Referenced by block_leader(), and reset().
Stable node storage.
Definition at line 94 of file Adaptive_Huffman.H.
Referenced by block_leader(), check_capacity(), Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Encoder::encode(), Aleph::Adaptive_Huffman_Encoder::frequency(), Aleph::Adaptive_Huffman_Decoder::frequency(), reset(), swap_nodes(), Aleph::Adaptive_Huffman_Encoder::symbols_processed(), Aleph::Adaptive_Huffman_Decoder::symbols_processed(), and update().
| int Aleph::adaptive_huffman_detail::Model::nyt = root |
Current NYT node index.
Definition at line 97 of file Adaptive_Huffman.H.
Referenced by Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Encoder::encode(), reset(), and update().
|
staticconstexpr |
Stable root node index.
Definition at line 71 of file Adaptive_Huffman.H.
Referenced by check_capacity(), Aleph::Adaptive_Huffman_Decoder::decode_bit(), Aleph::Adaptive_Huffman_Decoder::has_pending_symbol(), reset(), Aleph::Adaptive_Huffman_Decoder::reset(), Aleph::Adaptive_Huffman_Encoder::symbols_processed(), and Aleph::Adaptive_Huffman_Decoder::symbols_processed().
| int Aleph::adaptive_huffman_detail::Model::used = 1 |
Number of active nodes.
Definition at line 98 of file Adaptive_Huffman.H.