46template <
class Key,
class Value >
156 iter->second.m_parent =
this;
184 children.
insert ( * begin ).first->second.m_parent =
this;
197 for ( std::pair < const Key, trie > & child : m_children )
198 child.second.m_parent =
this;
220 template <
typename ... Types >
221 trie (
const Value & data, Types ... subtries ) :
trie ( data,
ext::
map < Key,
trie > { subtries ... } ) {
233 template <
typename ... Types >
260 trie ( const
trie & other ) : m_data ( other.m_data ), m_parent ( other.m_parent ), m_children ( other.m_children ) {
261 for ( std::pair < const Key, trie > & child : m_children )
262 child.second.m_parent =
this;
271 trie (
trie && other ) noexcept : m_data ( std::move ( other.m_data ) ), m_parent ( other.m_parent ), m_children ( std::move ( other.m_children ) ) {
272 for ( std::pair < const Key, trie > & child : m_children )
273 child.second.m_parent =
this;
298 m_data = std::move (
node.m_data );
299 m_children = std::move (
node.m_children );
301 for ( std::pair < const Key, trie > & child : m_children )
302 child.second.m_parent =
this;
316 return m_children.
begin ( );
326 return m_children.
begin ( );
336 return m_children.
end ( );
346 return m_children.
end ( );
360 return children.
erase ( position );
375 template <
class ... Indexes >
392 node = &
node->getChildren ( ).find ( index )->second;
395 return node->getData ( );
408 template <
class ... Indexes >
425 node = &
node->getChildren ( ).find ( index )->second;
428 return node->getData ( );
444 for (
const std::pair < const Key, trie > & child :
node.getChildren ( ) )
474 for (
trie & child : first.m_children )
475 child.m_parent = & first;
477 child.m_parent = &
second;
502 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 > ( ) ) > {
532 std::string prefix (
" " );
534 os <<
getData ( ) << std::endl;
538 os << prefix <<
"|" << std::endl;
539 nicePrint ( os, subdata, prefix,
i == m_children.size ( ) - 1 );
579 os << data.first <<
":" << data.second.getData ( ) << std::endl;
582 for (
const std::pair <
const Key, trie < Key, Value > > & subdata : data.second ) {
583 os << prefix <<
"|" << std::endl;
584 nicePrint ( os, subdata, prefix,
i == data.second.m_children.size ( ) - 1 );
602template <
class Key,
class Value >
613 out << iter->first <<
":" << iter->second;
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: map.hpp:185
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
auto end() &
Inherited behavior of end for non-const instance.
Definition: map.hpp:215
typename std::map< T, R, Cmp, Alloc >::iterator iterator
The iterator type is inheried.
Definition: map.hpp:101
size_t erase(const K &key)
Erase by key of arbitrary type.
Definition: map.hpp:340
Class introducing a trie with interface trying to be close to the interface of standard library conta...
Definition: trie.hpp:47
const_children_iterator begin() const
Getter of a children iterator to the begining of children.
Definition: trie.hpp:315
ext::map< Key, trie >::const_iterator const_children_iterator
The iterator type over children of the node.
Definition: trie.hpp:139
trie(trie &&other) noexcept
Move constructor of the trie.
Definition: trie.hpp:271
friend void swap(trie &first, trie &second)
Swap method of two tries.
Definition: trie.hpp:471
children_iterator erase(const_children_iterator position)
Erases a subtrie from a trie on given by position.
Definition: trie.hpp:357
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 cons...
Definition: trie.hpp:245
const ext::map< Key, trie > & getChildren() const
Getter of children of the root node.
Definition: trie.hpp:125
trie(Value &&data, ext::map< Key, trie > &&children)
Constructor of the trie from value to be stored in the root node and children tries.
Definition: trie.hpp:196
const trie * getParent() const
Getter of the parent node. Null if the node is root.
Definition: trie.hpp:85
~trie() noexcept=default
Dectructor of the trie.
ext::ostream & nicePrint(ext::ostream &os) const
Internal method of printing a trie into a stream.
Definition: trie.hpp:530
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.
Definition: trie.hpp:502
trie(const Value &data, Types ... subtries)
Constructor of the trie from value to be stored in the root node and pack of children tries.
Definition: trie.hpp:221
children_iterator end()
Getter of a children iterator one after the last child.
Definition: trie.hpp:345
void insert(const_children_iterator begin, const_children_iterator end)
Inserts subtries given by range of key-value pairs at specified position.
Definition: trie.hpp:180
ext::map< Key, trie > & getChildren()
Getter of children of the root node.
Definition: trie.hpp:115
const_children_iterator insert(Key key, const trie< Key, Value > &value)
Inserts a subtrie into a trie.
Definition: trie.hpp:169
trie * getParent()
Getter of the parent node. Null if the node is root.
Definition: trie.hpp:75
bool operator==(const trie &other) const
Equality comparison operator.
Definition: trie.hpp:490
const Value & getData() const
Getter of the value in the root node.
Definition: trie.hpp:105
const Value & operator()(Indexes ... indexes) const
Access value given indexes to chindren allong the selection path.
Definition: trie.hpp:376
Value & getData()
Getter of the value in the root node.
Definition: trie.hpp:95
bool checkStructure() const
Helper method to traverse the trie and check all parent references are set correctly....
Definition: trie.hpp:458
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.
Definition: trie.hpp:208
const_children_iterator insert(Key key, trie< Key, Value > &&value)
Inserts a subtrie into a trie.
Definition: trie.hpp:152
trie(Value &&data, Types ... subtries)
Constructor of the trie from value to be stored in the root node and pack of children tries.
Definition: trie.hpp:234
bool checkStructure(const trie &node) const
Helper method to traverse the trie and check all parent references are set correctly.
Definition: trie.hpp:441
const_children_iterator end() const
Getter of a children iterator one after the last child.
Definition: trie.hpp:335
children_iterator begin()
Getter of a children iterator to the begining of children.
Definition: trie.hpp:325
trie & operator=(const trie &node)
Copy operator of assignment of the trie.
Definition: trie.hpp:284
ext::map< Key, trie >::iterator children_iterator
The iterator type over children of the node.
Definition: trie.hpp:133
p second
Definition: ToRegExpAlgebraic.h:126
int i
Definition: AllEpsilonClosure.h:118
Definition: sigHandler.cpp:20
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218
std::ostream & operator<<(ext::reference_wrapper< std::ostream > &os, std::ostream &(*const func)(std::ostream &))
Overloaded function allowing same operations on wrapped output stream as on the actual output stream,...
Definition: GlobalData.cpp:33
Definition: CompressedBitParallelTreeIndex.h:40
Definition: FordFulkerson.hpp:16