Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
|
Class introducing a trie with interface trying to be close to the interface of standard library containers. More...
#include <trie.hpp>
Public Types | |
typedef ext::map< Key, trie >::iterator | children_iterator |
The iterator type over children of the node. More... | |
typedef ext::map< Key, trie >::const_iterator | const_children_iterator |
The iterator type over children of the node. More... | |
Public Member Functions | |
trie * | getParent () |
Getter of the parent node. Null if the node is root. More... | |
const trie * | getParent () const |
Getter of the parent node. Null if the node is root. More... | |
Value & | getData () |
Getter of the value in the root node. More... | |
const Value & | getData () const |
Getter of the value in the root node. More... | |
ext::map< Key, trie > & | getChildren () |
Getter of children of the root node. More... | |
const ext::map< Key, trie > & | getChildren () const |
Getter of children of the root node. More... | |
const_children_iterator | insert (Key key, trie< Key, Value > &&value) |
Inserts a subtrie into a trie. More... | |
const_children_iterator | insert (Key key, const trie< Key, Value > &value) |
Inserts a subtrie into a trie. More... | |
void | insert (const_children_iterator begin, const_children_iterator end) |
Inserts subtries given by range of key-value pairs at specified position. More... | |
trie (Value &&data, ext::map< Key, trie > &&children) | |
Constructor of the trie from value to be stored in the root node and children tries. More... | |
trie (const Value &data, const ext::map< Key, trie > &subtries) | |
Constructor of the trie from value to be stored in the root node and children tries. More... | |
template<typename ... Types> | |
trie (const Value &data, Types ... subtries) | |
Constructor of the trie from value to be stored in the root node and pack of children tries. More... | |
template<typename ... Types> | |
trie (Value &&data, Types ... subtries) | |
Constructor of the trie from value to be stored in the root node and pack of children tries. More... | |
trie (const Value &data, const_children_iterator begin, const_children_iterator end) | |
Constructor of the trie from value to be stored in the root node and range of key-value pairs to construct nullary nodes. More... | |
~trie () noexcept=default | |
Dectructor of the trie. More... | |
trie (const trie &other) | |
Copy constructor of the trie. More... | |
trie (trie &&other) noexcept | |
Move constructor of the trie. More... | |
trie & | operator= (const trie &node) |
Copy operator of assignment of the trie. More... | |
trie & | operator= (trie &&node) noexcept |
Move operator of assignment of the trie. More... | |
const_children_iterator | begin () const |
Getter of a children iterator to the begining of children. More... | |
children_iterator | begin () |
Getter of a children iterator to the begining of children. More... | |
const_children_iterator | end () const |
Getter of a children iterator one after the last child. More... | |
children_iterator | end () |
Getter of a children iterator one after the last child. More... | |
children_iterator | erase (const_children_iterator position) |
Erases a subtrie from a trie on given by position . More... | |
template<class ... Indexes> | |
const Value & | operator() (Indexes ... indexes) const |
Access value given indexes to chindren allong the selection path. More... | |
const Value & | operator() (std::initializer_list< Key > indexes) const |
Access value given key to chindren allong the selection path. More... | |
template<class ... Indexes> | |
Value & | operator() (Indexes ... indexes) |
Access value given indexes to chindren allong the selection path. More... | |
Value & | operator() (std::initializer_list< Key > indexes) |
Access value given key to chindren allong the selection path. More... | |
bool | checkStructure (const trie &node) const |
Helper method to traverse the trie and check all parent references are set correctly. More... | |
bool | checkStructure () const |
Helper method to traverse the trie and check all parent references are set correctly. Starts at root node and recursively tests all its child nodes. More... | |
bool | operator== (const trie &other) const |
Equality comparison operator. More... | |
auto | operator<=> (const trie &other) const -> std::common_comparison_category_t< decltype(std::declval< Key >()<=> std::declval< Key >()), decltype(std::declval< Value >()<=> std::declval< Value >()) > |
Less comparison operator. More... | |
ext::ostream & | nicePrint (ext::ostream &os) const |
Internal method of printing a trie into a stream. More... | |
Friends | |
void | swap (trie &first, trie &second) |
Swap method of two tries. More... | |
Class introducing a trie with interface trying to be close to the interface of standard library containers.
The trie is a hierarchical structure of nodes with parent child relationship, where the children are accessible by their keys.
T | the type of values inside nodes of the trie |
typedef ext::map<Key,trie>::iterator ext::trie< Key, Value >::children_iterator |
The iterator type over children of the node.
typedef ext::map<Key,trie>::const_iterator ext::trie< Key, Value >::const_children_iterator |
The iterator type over children of the node.
|
inline |
Constructor of the trie from value to be stored in the root node and children tries.
data | the value to be stored in the root |
children | map of subtries |
|
inline |
Constructor of the trie from value to be stored in the root node and children tries.
data | the value to be stored in the root |
children | map of subtries |
|
inline |
Constructor of the trie from value to be stored in the root node and pack of children tries.
Types | ... pack of types convertible to trie |
data | the value to be stored in the root |
subtries | ... pack of subtries |
|
inline |
Constructor of the trie from value to be stored in the root node and pack of children tries.
Types | ... pack of types convertible to trie |
data | the value to be stored in the root |
subtries | ... pack of subtries |
|
inline |
Constructor of the trie from value to be stored in the root node and range of key-value pairs to construct nullary nodes.
data | the value to be stored in the root |
begin | the iterator to the begining of key-value pairs range |
end | the iterator to the end of key-value pairs range |
Dectructor of the trie.
|
inline |
Copy constructor of the trie.
other | the other instace of the trie |
|
inlinenoexcept |
Move constructor of the trie.
other | the other instace of the trie |
|
inline |
Getter of a children iterator to the begining of children.
|
inline |
Getter of a children iterator to the begining of children.
|
inline |
Helper method to traverse the trie and check all parent references are set correctly. Starts at root node and recursively tests all its child nodes.
node | the node to test |
|
inline |
Helper method to traverse the trie and check all parent references are set correctly.
node | the node to test |
|
inline |
Getter of a children iterator one after the last child.
|
inline |
Getter of a children iterator one after the last child.
|
inline |
Erases a subtrie from a trie on given by position
.
position | the specification of position in children where to erase the subtrie |
|
inline |
Getter of children of the root node.
|
inline |
Getter of children of the root node.
|
inline |
Getter of the value in the root node.
|
inline |
Getter of the value in the root node.
Getter of the parent node. Null if the node is root.
Getter of the parent node. Null if the node is root.
|
inline |
Inserts subtries given by range of key-value pairs at specified position.
begin | the start of the range of subtries |
end | the end of the range of subtries |
|
inline |
Inserts a subtrie into a trie.
key | the associating key for the inserted subtrie |
value | a subtrie to insert |
|
inline |
Inserts a subtrie into a trie.
key | the associating key for the inserted subtrie |
value | a subtrie to insert |
|
inline |
Internal method of printing a trie into a stream.
The trie is printed hierarchically. Key-value pair components are printed separated by colon.
Example trie a ( k:b ( m:c ), l:b ( n:c ) ) would be printed like
-a | |-k:b | | | -m:c | -l:b | -n:c
os | the stream to print to |
|
inline |
Access value given indexes to chindren allong the selection path.
Indexes | ... types of child keys |
indexes | actual keys |
|
inline |
Access value given indexes to chindren allong the selection path.
Indexes | ... types of child keys |
indexes | actual keys |
|
inline |
Access value given key to chindren allong the selection path.
indexes | list of actual keys |
|
inline |
Access value given key to chindren allong the selection path.
indexes | list of actual keys |
|
inline |
Less comparison operator.
other | the other instance to compare with |
|
inline |
Copy operator of assignment of the trie.
other | the other instace of the trie |
|
inlinenoexcept |
Move operator of assignment of the trie.
other | the other instace of the trie |
|
inline |
Equality comparison operator.
other | the other instance to compare with |
|
friend |
Swap method of two tries.
first | the first forward trie to swap |
second | the second forward trie to swap |