|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Compressed bitwise set for unsigned integral keys. More...
#include <tpl_patricia_trie.H>
Classes | |
| struct | Node |
Public Types | |
| using | Key = UInt |
| Key type stored by the set. | |
Public Member Functions | |
| PatriciaSet ()=default | |
| Construct an empty set. | |
| ~PatriciaSet ()=default | |
| Destructor. | |
| PatriciaSet (const PatriciaSet &other) | |
| Deep-copy constructor. | |
| PatriciaSet & | operator= (const PatriciaSet &other) |
| Deep-copy assignment. | |
| PatriciaSet (PatriciaSet &&other) noexcept | |
| Move constructor. | |
| PatriciaSet & | operator= (PatriciaSet &&other) noexcept |
| Move assignment. | |
| size_t | size () const noexcept |
| Return the number of stored keys. | |
| bool | is_empty () const noexcept |
| Check whether the set has no keys. | |
| void | clear () noexcept |
| Remove every key from the set. | |
| bool | contains (const Key key) const noexcept |
Check whether key is stored. | |
| bool | insert (const Key key) |
Insert key if absent. | |
| bool | erase (const Key key) noexcept |
Remove key if present. | |
| Array< Key > | keys () const |
| Return all stored keys. | |
| bool | check_invariants () const noexcept |
| Verify structural invariants recursively. | |
Static Public Attributes | |
| static constexpr size_t | bit_width = std::numeric_limits<Key>::digits |
Number of significant bits in Key. | |
Private Types | |
| using | Detail = patricia_trie_detail::Bitwise_Trie_Utils< Key > |
Static Private Member Functions | |
| static std::unique_ptr< Node > | clone_node (const Node *src) |
Private Attributes | |
| std::unique_ptr< Node > | root_ |
| size_t | size_ = 0 |
Compressed bitwise set for unsigned integral keys.
PatriciaSet is a PATRICIA/crit-bit tree over the fixed-width bit pattern of UInt. It stores unique keys only; use RadixTree when string keys or mapped values are required.
| UInt | Unsigned integral key type. bool is rejected because it has only two values and does not benefit from a trie representation. |
Definition at line 324 of file tpl_patricia_trie.H.
|
private |
Definition at line 347 of file tpl_patricia_trie.H.
Key type stored by the set.
Definition at line 328 of file tpl_patricia_trie.H.
|
default |
Construct an empty set.
| Nothing. |
|
default |
Destructor.
Recursively releases every node.
| Nothing. |
|
inline |
Deep-copy constructor.
| [in] | other | Set to copy. |
| std::bad_alloc | if cloning nodes fails. |
Definition at line 378 of file tpl_patricia_trie.H.
|
inlinenoexcept |
Move constructor.
| [in,out] | other | Source set, left empty. |
| Nothing. |
Definition at line 401 of file tpl_patricia_trie.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
Verify structural invariants recursively.
Checks that internal nodes have two children, internal bit indexes strictly increase down every path, each child subtree matches the routing bit used to reach it, and the number of leaves equals size().
true iff all invariants hold. | Nothing. |
Definition at line 524 of file tpl_patricia_trie.H.
References Aleph::and, and Aleph::blossom_maximum_cardinality_matching().
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Remove every key from the set.
| Nothing. |
Definition at line 444 of file tpl_patricia_trie.H.
Referenced by TEST().
|
inlinenoexcept |
Check whether key is stored.
| [in] | key | Key to query. |
true if key is present. | Nothing. |
Definition at line 455 of file tpl_patricia_trie.H.
References Aleph::and, and Aleph::PatriciaSet< UInt >::Node::key.
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
Insert key if absent.
| [in] | key | Key to insert. |
true if inserted, false if it was already present. | std::bad_alloc | if allocating a new leaf or internal node fails. |
Definition at line 466 of file tpl_patricia_trie.H.
References Aleph::and, and Aleph::blossom_maximum_cardinality_matching().
Referenced by TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and TEST().
|
inlinenoexcept |
Return all stored keys.
Array containing every key in unspecified order. | std::bad_alloc | if the returned array cannot grow. |
Definition at line 507 of file tpl_patricia_trie.H.
References Aleph::Array< T >::reserve().
|
inline |
Deep-copy assignment.
| [in] | other | Set to copy. |
*this. | std::bad_alloc | if cloning nodes fails. |
Definition at line 387 of file tpl_patricia_trie.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
Move assignment.
| [in,out] | other | Source set, left empty. |
*this. | Nothing. |
Definition at line 412 of file tpl_patricia_trie.H.
References Aleph::blossom_maximum_cardinality_matching().
|
inlinenoexcept |
|
staticconstexpr |
Number of significant bits in Key.
Definition at line 331 of file tpl_patricia_trie.H.
|
private |
Definition at line 345 of file tpl_patricia_trie.H.
|
private |
Definition at line 346 of file tpl_patricia_trie.H.