37#ifndef __cpp_lib_three_way_comparison
38#include <extensions/compare.hpp>
200 if ( virtual_node ) {
201 const tree * parent =
node->getParent ( );
204 if ( parent !=
nullptr ) {
209 virtual_node =
false;
212 virtual_node =
false;
216 if ( !
node->getChildren ( ).empty ( ) ) {
218 node = & *
node->getChildren ( ).begin ( );
251 }
else if ( virtual_node ) {
252 if ( !
node->getChildren ( ).empty ( ) ) {
255 node = & * --
node->getChildren ( ).end ( );
257 virtual_node =
false;
260 const tree * parent =
node->getParent ( );
262 if ( parent !=
nullptr ) {
298 return node == other.node && virtual_node == other.virtual_node;
310 return !( *
this == other );
320 return node->getData ( );
330 return &
node->getData ( );
393 while ( ( ++
node ).getVirtual ( ) );
418 while ( ( --
node ).getVirtual ( ) );
445 return node == other.node;
457 return !( *
this == other );
477 return &
node->getData ( );
487 return node.getLevel ( );
530 while ( !( ++
node ).getVirtual ( ) && !
node.isEnd );
555 while ( !( --
node ).getVirtual ( ) );
582 return node == other.node;
594 return !( *
this == other );
614 return &
node->getData ( );
624 return node.getLevel ( );
645 template <
class Iterator >
666 value.m_parent =
this;
667 return m_children.
insert ( position, std::move ( value ) );
697 iterCopy->m_parent =
this;
714 template <
class Iterator >
718 return insert ( position, children.cbegin ( ), children.cend ( ) );
732 for (
tree & child : m_children )
733 child.m_parent =
this;
755 template <
typename ... Types >
768 template <
typename ... Types >
780 template <
typename Iterator >
807 tree ( const
tree & other ) : m_data ( other.m_data ), m_parent ( other.m_parent ), m_children ( other.m_children ) {
808 for (
tree & child : m_children )
809 child.m_parent =
this;
818 tree (
tree && other ) noexcept : m_data ( std::move ( other.m_data ) ), m_parent ( other.m_parent ), m_children ( std::move ( other.m_children ) ) {
819 for (
tree & child : m_children )
820 child.m_parent =
this;
845 m_data = std::move (
node.m_data );
846 m_children = std::move (
node.m_children );
848 for (
tree & child : m_children )
849 child.m_parent =
this;
863 return m_children.
begin ( );
873 return m_children.
begin ( );
883 return m_children.
end ( );
893 return m_children.
end ( );
917 res.node.isEnd =
true;
932 while ( !
res.node.getVirtual ( ) ) ++
res.node;
946 res.node.isEnd =
true;
984 m_children.push_back ( std::move ( value ) );
985 m_children.back ( ).m_parent =
this;
1027 return m_children.
erase ( position );
1042 template <
class ... Indexes >
1044 return this->
operator ()( {
static_cast < size_t > ( indexes ) ... } );
1058 for (
size_t index :
indexes ) {
1059 node = &
node->getChildren ( )[index];
1062 return node->getData ( );
1075 template <
class ... Indexes >
1077 return this->
operator ()( {
static_cast < size_t > ( indexes ) ... } );
1091 for (
size_t index :
indexes ) {
1092 node = &
node->getChildren ( )[index];
1095 return node->getData ( );
1111 for (
const tree & child :
node.getChildren ( ) )
1142 swap ( first.m_children,
second.m_children );
1143 for (
tree & child : first.m_children )
1144 child.m_parent = & first;
1146 child.m_parent = &
second;
1171 auto operator <=> (
const tree & other )
const ->
decltype ( std::declval < T > ( ) <=> std::declval < T > ( ) ) {
1238 os <<
getData ( ) << std::endl;
1240 for (
size_t i = 0;
i < m_children.size ( ); ++
i ) {
1241 os << prefix <<
"|" << std::endl;
1242 m_children[
i].nicePrint ( os, prefix,
i == m_children.size ( ) - 1 );
1266 while ( iter.getLevel ( ) > level ) {
1271 out << level << * iter;
1274 bool printComma = iter.getLevel ( ) == level;
1276 while ( iter.getLevel ( ) < level ) {
1282 if ( printComma && ( level != 0 ) )
The iterator type over structure of the tree following postorder traversal.
Definition: tree.hpp:500
bool operator!=(const const_postfix_iterator &other) const
Compare the iterators for nonequality.
Definition: tree.hpp:593
T value_type
Definition: tree.hpp:509
const T * pointer
Definition: tree.hpp:510
const T * operator->() const
Dereference the iterator by accessing the pointed node value.
Definition: tree.hpp:613
std::ptrdiff_t difference_type
Definition: tree.hpp:508
bool operator==(const const_postfix_iterator &other) const
Compare the iterators for equality.
Definition: tree.hpp:581
const_postfix_iterator(const tree *n)
Constructor of the iterator based on the iterator to child list.
Definition: tree.hpp:520
std::bidirectional_iterator_tag iterator_category
Definition: tree.hpp:512
const_postfix_iterator & operator--()
Retract the iterator.
Definition: tree.hpp:554
const T & operator*() const
Dereference the iterator by accessing the pointed node value.
Definition: tree.hpp:603
const T & reference
Definition: tree.hpp:511
const_postfix_iterator & operator++()
Advances the iterator.
Definition: tree.hpp:529
size_t getLevel() const
Retrieves what is the depth of node the iterator is pointing to.
Definition: tree.hpp:623
The iterator type over structure of the tree following preorder traversal.
Definition: tree.hpp:363
size_t getLevel() const
Retrieves what is the depth of node the iterator is pointing to.
Definition: tree.hpp:486
const_prefix_iterator(const tree *n)
Constructor of the iterator based on the iterator to child list.
Definition: tree.hpp:383
const T * pointer
Definition: tree.hpp:373
bool operator==(const const_prefix_iterator &other) const
Compare the iterators for equality.
Definition: tree.hpp:444
T value_type
Definition: tree.hpp:372
bool operator!=(const const_prefix_iterator &other) const
Compare the iterators for nonequality.
Definition: tree.hpp:456
const_prefix_iterator & operator++()
Advance the iterator.
Definition: tree.hpp:392
const T & operator*() const
Dereference the iterator by accessing the pointed node value.
Definition: tree.hpp:466
std::bidirectional_iterator_tag iterator_category
Definition: tree.hpp:375
const_prefix_iterator & operator--()
Retract the iterator.
Definition: tree.hpp:417
std::ptrdiff_t difference_type
Definition: tree.hpp:371
const T * operator->() const
Dereference the iterator by accessing the pointed node value.
Definition: tree.hpp:476
const T & reference
Definition: tree.hpp:374
The iterator type over structure of the tree representing nodes and node_ends.
Definition: tree.hpp:152
const T * operator->() const
Dereference the iterator by accessing the pointed node value.
Definition: tree.hpp:329
const_structure_iterator & operator++()
Advance the iterator.
Definition: tree.hpp:199
bool operator==(const const_structure_iterator &other) const
Compare the iterators for equality.
Definition: tree.hpp:297
const_structure_iterator(const tree *n)
Constructor of the iterator based on the iterator to child list.
Definition: tree.hpp:190
const T & operator*() const
Dereference the iterator by accessing the pointed node value.
Definition: tree.hpp:319
bool getVirtual() const
Allows to distinguish entry or leave visit of a pointed to node.
Definition: tree.hpp:349
T value_type
Definition: tree.hpp:179
const_structure_iterator & operator--()
Retract the iterator.
Definition: tree.hpp:246
size_t getLevel() const
Retrieves what is the depth of node the iterator is pointing to.
Definition: tree.hpp:339
std::bidirectional_iterator_tag iterator_category
Definition: tree.hpp:182
bool operator!=(const const_structure_iterator &other) const
Compare the iterators for nonequality.
Definition: tree.hpp:309
const T * pointer
Definition: tree.hpp:180
const T & reference
Definition: tree.hpp:181
std::ptrdiff_t difference_type
Definition: tree.hpp:178
Class introducing a tree with interface trying to be close to the interface of standard library conta...
Definition: tree.hpp:52
children_iterator begin()
Getter of a children iterator to the begining of children.
Definition: tree.hpp:872
const_structure_iterator structure_end() const
Getter of the structure iterator to one after the last node in the traversal.
Definition: tree.hpp:968
children_iterator end()
Getter of a children iterator one after the last child.
Definition: tree.hpp:892
const_children_iterator insert(const_children_iterator position, const_children_iterator begin, const_children_iterator end)
Inserts subtrees given by range of values at specified position.
Definition: tree.hpp:693
const_postfix_iterator postfix_begin() const
Getter of the postfix iterator to the first node in the postfix traversal.
Definition: tree.hpp:929
const_children_iterator end() const
Getter of a children iterator one after the last child.
Definition: tree.hpp:882
void push_back(T &&value)
Pushbacks a nullary node after last child of a tree.
Definition: tree.hpp:1004
friend void swap(tree &first, tree &second)
Swap method of two trees.
Definition: tree.hpp:1138
const_children_iterator insert(const_children_iterator position, tree< T > &&value)
Inserts a subtree into a tree.
Definition: tree.hpp:665
const_children_iterator begin() const
Getter of a children iterator to the begining of children.
Definition: tree.hpp:862
const tree * getParent() const
Getter of the parent node. Null if the node is root.
Definition: tree.hpp:90
tree * getParent()
Getter of the parent node. Null if the node is root.
Definition: tree.hpp:80
const_prefix_iterator prefix_begin() const
Getter of the prefix iterator to the root node.
Definition: tree.hpp:904
bool checkStructure() const
Helper method to traverse the tree and check all parent references are set correctly....
Definition: tree.hpp:1125
children_iterator erase(const_children_iterator position)
Erases a subtree from a tree on given by position.
Definition: tree.hpp:1026
~tree() noexcept=default
Dectructor of the tree.
tree(const T &data, Iterator begin, Iterator end)
Constructor of the tree from value to be stored in the root node and range of values to construct nul...
Definition: tree.hpp:781
T & getData()
Getter of the value in the root node.
Definition: tree.hpp:100
void push_back(const T &value)
Pushbacks a nullary node after last child of a tree.
Definition: tree.hpp:1014
const T & getData() const
Getter of the value in the root node.
Definition: tree.hpp:110
void push_back(const ext::tree< T > &value)
Pushbacks a subtree after last child of a tree.
Definition: tree.hpp:994
tree(const T &data, const_children_iterator begin, const_children_iterator end)
Constructor of the tree from value to be stored in the root node and range of subtrees.
Definition: tree.hpp:792
const_children_iterator insert(const_children_iterator position, const tree< T > &value)
Inserts a subtree into a tree.
Definition: tree.hpp:679
bool checkStructure(const tree &node) const
Helper method to traverse the tree and check all parent references are set correctly.
Definition: tree.hpp:1108
tree(T &&data, ext::vector< tree > &&children)
Constructor of the tree from value to be stored in the root node and children trees.
Definition: tree.hpp:731
const_structure_iterator structure_begin() const
Getter of the structure iterator to the first node in the traversal.
Definition: tree.hpp:958
tree(const T &data, const ext::vector< tree > &subtrees)
Constructor of the tree from value to be stored in the root node and children trees.
Definition: tree.hpp:743
tree & operator=(const tree &node)
Copy operator of assignment of the tree.
Definition: tree.hpp:831
const T & operator()(Indexes ... indexes) const
Access value given indexes of chindren allong the selection path.
Definition: tree.hpp:1043
ext::ostream & nicePrint(ext::ostream &os) const
Method of printing a tree into a stream.
Definition: tree.hpp:1199
void push_back(ext::tree< T > &&value)
Pushbacks a subtree after last child of a tree.
Definition: tree.hpp:983
const_postfix_iterator postfix_end() const
Getter of the postfix iterator one after the last node in the postfix traversal.
Definition: tree.hpp:943
bool operator==(const tree &other) const
Equality comparison operator.
Definition: tree.hpp:1159
tree(const T &data, Types ... subtrees)
Constructor of the tree from value to be stored in the root node and pack of children trees.
Definition: tree.hpp:756
ext::vector< tree >::iterator children_iterator
The iterator type over children of the node.
Definition: tree.hpp:144
auto operator<=>(const tree &other) const -> decltype(std::declval< T >()<=> std::declval< T >())
Greater or equal comparison operator.
Definition: tree.hpp:1171
const_children_iterator insert(const_children_iterator position, Iterator begin, Iterator end)
Inserts a subtrees into a tree. The subtrees are nullary nodes having value given by values in the ra...
Definition: tree.hpp:715
ext::vector< tree >::const_iterator const_children_iterator
The iterator type over children of the node.
Definition: tree.hpp:138
tree(tree &&other) noexcept
Move constructor of the tree.
Definition: tree.hpp:818
const_prefix_iterator prefix_end() const
Getter of the prefix iterator one after the last node in the prefix traversal.
Definition: tree.hpp:914
ext::vector< tree > & getChildren()
Getter of children of the root node.
Definition: tree.hpp:120
const ext::vector< tree > & getChildren() const
Getter of children of the root node.
Definition: tree.hpp:130
tree(T &&data, Types ... subtrees)
Constructor of the tree from value to be stored in the root node and pack of children trees.
Definition: tree.hpp:769
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
auto begin() &
Inherited behavior of begin for non-const instance.
Definition: vector.hpp:125
iterator erase(iterator pos)
Removes element from the container at position given by parameter pos.
Definition: vector.hpp:323
typename std::vector< T, Alloc >::iterator iterator
The type of values iterator.
Definition: vector.hpp:61
typename std::vector< T, Alloc >::const_iterator const_iterator
The type of constant values iterator.
Definition: vector.hpp:67
reverse_iterator insert(const_reverse_iterator pos, const T &value)
Inserts the value on position given by iterator pos.
Definition: vector.hpp:229
auto end() &
Inherited behavior of end for non-const instance.
Definition: vector.hpp:155
p second
Definition: ToRegExpAlgebraic.h:126
int i
Definition: AllEpsilonClosure.h:118
return res
Definition: MinimizeByPartitioning.h:145
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
void swap(ext::managed_linear_set< T, Compare, Alloc > &x, ext::managed_linear_set< T, Compare, Alloc > &y)
Specialisation of swap for linear set.
Definition: managed_linear_set.hpp:864
Definition: BackwardOccurrenceTest.h:17