Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
tree_base.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include "ptr_vector.hpp"
9#include "ptr_array.hpp"
10
11namespace ext {
12
19template < class Data >
20class BaseNode {
25 Data * parent;
26
27 template < class D, class C >
28 friend class NullaryNode;
29 template < class D, class C >
30 friend class UnaryNode;
31 template < class D, class C >
32 friend class BinaryNode;
33 template < class D, class C >
34 friend class TernaryNode;
35 template < class D, std::size_t I, class C >
36 friend class AnyaryNode;
37 template < class D, class C >
38 friend class FixedaryNode;
39 template < class D, class C >
40 friend class VararyNode;
41
48 Data * operator ->( ) {
49 return static_cast < Data * > ( this );
50 }
51
58 const Data * operator ->( ) const {
59 return static_cast < const Data * > ( this );
60 }
61
62public:
67 BaseNode ( ) : parent ( nullptr ) {
68 }
69
74 virtual ~BaseNode ( ) noexcept = default;
75
80 BaseNode ( const BaseNode & ) : parent ( nullptr ) {
81 }
82
87 BaseNode ( BaseNode && ) noexcept : parent ( nullptr ) {
88 }
89
95 return * this;
96 }
97
102 BaseNode & operator =( BaseNode && ) noexcept {
103 return * this;
104 }
105
112 Data * getParent ( ) {
113 return parent;
114 }
115
122 const Data * getParent ( ) const {
123 return parent;
124 }
125
126};
127
136template < class Data, std::size_t arity, class Base = Data >
137class AnyaryNode : public Base {
143
148 void setParents ( ) {
149 for ( Data & child : m_children )
150 child->parent = this;
151 }
152
153public:
160 AnyaryNode ( ext::ptr_array < Data, arity > c ) : m_children ( std::move ( c ) ) {
161 setParents ( );
162 }
163
168 ~AnyaryNode ( ) noexcept override = default;
169
174 AnyaryNode ( const AnyaryNode & other ) : AnyaryNode ( other.m_children ) {
175 }
176
181 AnyaryNode ( AnyaryNode && other ) noexcept : AnyaryNode ( std::move ( other.m_children ) ) {
182 }
183
188 AnyaryNode & operator =( const AnyaryNode & other ) {
189 if ( this == & other )
190 return * this;
191
192 this->m_children = other.m_children;
193
194 setParents ( );
195
196 return * this;
197 }
198
203 AnyaryNode & operator =( AnyaryNode && other ) noexcept {
204 using std::swap;
205
206 swap ( this->m_children, other.m_children );
207
208 setParents ( );
209
210 return * this;
211 }
212
220 return m_children;
221 }
222
230 return m_children;
231 }
232
240 return std::move ( m_children );
241 }
242
251 template < size_t N >
252 const Data & getChild ( ) const {
253 return std::get < N > ( m_children );
254 }
255
264 template < size_t N >
265 Data & getChild ( ) {
266 return std::get < N > ( m_children );
267 }
268
276 m_children = std::move ( c );
277 setParents ( );
278 }
279
288 template < size_t N >
289 void setChild ( const Data & d ) {
290 m_children.set ( m_children.cbegin ( ) + N, d );
291 std::get < N > ( m_children )->parent = this;
292 }
293
302 template < size_t N >
303 void setChild ( Data && d ) {
304 m_children.set ( m_children.cbegin ( ) + N, std::move ( d ) );
305 std::get < N > ( m_children )->parent = this;
306 }
307
315 return m_children.begin ( );
316 }
317
325 return m_children.begin ( );
326 }
327
335 return m_children.end ( );
336 }
337
345 return m_children.end ( );
346 }
347
348};
349
357template < class Data, class Base = Data >
358class NullaryNode : public AnyaryNode < Data, 0, Base > {
359public:
364 NullaryNode ( ) : AnyaryNode < Data, 0, Base > ( ext::make_ptr_array < Data > ( ) ) {
365 }
366
367};
368
376template < class Data, class Base = Data >
377class UnaryNode : public AnyaryNode < Data, 1, Base > {
378public:
385 UnaryNode ( const Data & c ) : AnyaryNode < Data, 1, Base > ( ext::make_ptr_array ( c ) ) {
386 }
387
394 UnaryNode ( Data && c ) : AnyaryNode < Data, 1, Base > ( ext::make_ptr_array ( std::move ( c ) ) ) {
395 }
396
403 Data & getChild ( ) {
404 return this->template getChild < 0 > ( );
405 }
406
413 const Data & getChild ( ) const {
414 return this->template getChild < 0 > ( );
415 }
416
422
429 void setChild ( const Data & c ) {
430 this->template setChild < 0 > ( c );
431 }
432
439 void setChild ( Data && c ) {
440 this->template setChild < 0 > ( std::move ( c ) );
441 }
442
448
449};
450
458template < class Data, class Base = Data >
460public:
468 BinaryNode ( const Data & l, const Data & r ) : AnyaryNode < Data, 2, Base > ( ext::make_ptr_array ( l, r ) ) {
469 }
470
478 BinaryNode ( Data && l, Data && r ) : AnyaryNode < Data, 2, Base > ( ext::make_ptr_array ( std::move ( l ), std::move ( r ) ) ) {
479 }
480
487 Data & getLeft ( ) {
488 return this->template getChild < 0 > ( );
489 }
490
497 const Data & getLeft ( ) const {
498 return this->template getChild < 0 > ( );
499 }
500
507 void setLeft ( const Data & l ) {
508 this->template setChild < 0 > ( l );
509 }
510
517 void setLeft ( Data && l ) {
518 this->template setChild < 0 > ( std::move ( l ) );
519 }
520
527 Data & getRight ( ) {
528 return this->template getChild < 1 > ( );
529 }
530
537 const Data & getRight ( ) const {
538 return this->template getChild < 1 > ( );
539 }
540
547 void setRight ( const Data & r ) {
548 this->template setChild < 1 > ( r );
549 }
550
557 void setRight ( Data && r ) {
558 this->template setChild < 1 > ( std::move ( r ) );
559 }
560
561};
562
570template < class Data, class Base = Data >
572public:
581 TernaryNode ( const Data & f, const Data & s, const Data & t ) : AnyaryNode < Data, 3, Base > ( ext::make_ptr_array ( f, s, t ) ) {
582 }
583
592 TernaryNode ( Data && f, Data && s, Data && t ) : AnyaryNode < Data, 3, Base > ( ext::make_ptr_array ( std::move ( f ), std::move ( s ), std::move ( t ) ) ) {
593 }
594
601 Data & getFirst ( ) {
602 return this->template getChild < 0 > ( );
603 }
604
611 const Data & getFirst ( ) const {
612 return this->template getChild < 0 > ( );
613 }
614
621 void setFirst ( const Data & f ) {
622 this->template setChild < 0 > ( f );
623 }
624
631 void setFirst ( Data && f ) {
632 this->template setChild < 0 > ( std::move ( f ) );
633 }
634
641 Data & getSecond ( ) {
642 return this->template getChild < 1 > ( );
643 }
644
651 const Data & getSecond ( ) const {
652 return this->template getChild < 1 > ( );
653 }
654
661 void setSecond ( const Data & s ) {
662 this->template setChild < 1 > ( s );
663 }
664
671 void setSecond ( Data && s ) {
672 this->template setChild < 1 > ( std::move ( s ) );
673 }
674
681 Data & getThird ( ) {
682 return this->template getChild < 2 > ( );
683 }
684
691 const Data & getThird ( ) const {
692 return this->template getChild < 2 > ( );
693 }
694
701 void setThird ( const Data & t ) {
702 this->template setChild < 2 > ( t );
703 }
704
711 void setThird ( Data && t ) {
712 this->template setChild < 2 > ( std::move ( t ) );
713 }
714
715};
716
724template < class Data, class Base = Data >
725class FixedaryNode : public Base {
730 ext::ptr_vector < Data > m_children;
731
732public:
739 FixedaryNode ( ext::ptr_vector < Data > c ) : m_children ( std::move ( c ) ) {
740 for ( Data & child : m_children )
741 child.parent = this;
742 }
743
752 template < typename ... Types >
753 FixedaryNode ( Types && ... data ) : FixedaryNode ( ext::ptr_vector < Data > ( { std::forward < Types > ( data ) ... } ) ) {
754 }
755
760 ~FixedaryNode ( ) noexcept override = default;
761
768 FixedaryNode ( const FixedaryNode & other ) : FixedaryNode ( other.m_children ) {
769 }
770
777 FixedaryNode ( FixedaryNode && other ) noexcept : FixedaryNode ( std::move ( other.m_children ) ) {
778 }
779
786 FixedaryNode & operator =( const FixedaryNode & other ) {
787 if ( this == & other )
788 return * this;
789
790 this->m_children = other.m_children;
791
792 for ( Data & child : m_children )
793 child.parent = this;
794
795 return * this;
796 }
797
804 FixedaryNode & operator =( FixedaryNode && other ) noexcept {
805 using std::swap;
806
807 swap ( this->m_children, other.m_children );
808
809 for ( Data & child : m_children )
810 child.parent = this;
811
812 return * this;
813 }
814
822 return m_children;
823 }
824
832 return m_children;
833 }
834
842 return std::move ( m_children );
843 }
844
852 if ( c.size ( ) != m_children.size ( ) )
853 throw "Arity != size";
854
855 m_children = std::move ( c );
856
857 for ( Data & child : m_children )
858 child->parent = this;
859 }
860
869 Data & getChild ( size_t index ) {
870 return m_children [ index ];
871 }
872
881 const Data & getChild ( size_t index ) const {
882 return m_children [ index ];
883 }
884
892 template < class PositionIterator >
893 void setChild ( Data && d, PositionIterator it ) {
894 m_children.set ( it, std::move ( d ) )->parent = this;
895 }
896
904 template < class PositionIterator >
905 void setChild ( const Data & d, PositionIterator it ) {
906 m_children.set ( it, d )->parent = this;
907 }
908
916 void setChild ( const Data & d, size_t index ) {
917 setChild ( d, m_children.begin ( ) + index );
918 }
919
927 void setChild ( Data && d, size_t index ) {
928 setChild ( std::move ( d ), m_children.begin ( ) + index );
929 }
930
938 return m_children.begin ( );
939 }
940
948 return m_children.begin ( );
949 }
950
958 return m_children.end ( );
959 }
960
968 return m_children.end ( );
969 }
970
971};
972
980template < class Data, class Base = Data >
981class VararyNode : public Base {
986 ext::ptr_vector < Data > m_children;
987
988public:
993 VararyNode ( ) = default;
994
1001 VararyNode ( ext::ptr_vector < Data > c ) : m_children ( std::move ( c ) ) {
1002 for ( Data & child : m_children )
1003 child.parent = this;
1004 }
1005
1010 ~VararyNode ( ) noexcept override = default;
1011
1018 VararyNode ( const VararyNode & other ) : VararyNode ( other.m_children ) {
1019 }
1020
1027 VararyNode ( VararyNode && other ) noexcept : VararyNode ( std::move ( other.m_children ) ) {
1028 }
1029
1036 VararyNode & operator =( const VararyNode & other ) {
1037 if ( this == & other )
1038 return * this;
1039
1040 this->m_children = other.m_children;
1041
1042 for ( Data & child : m_children )
1043 child.parent = this;
1044
1045 return * this;
1046 }
1047
1054 VararyNode & operator =( VararyNode && other ) noexcept {
1055 using std::swap;
1056
1057 swap ( this->m_children, other.m_children );
1058
1059 for ( Data & child : m_children )
1060 child.parent = this;
1061
1062 return * this;
1063 }
1064
1072 return m_children;
1073 }
1074
1082 return m_children;
1083 }
1084
1092 return std::move ( m_children );
1093 }
1094
1102 m_children = std::move ( c );
1103
1104 for ( Data & child : m_children )
1105 child.parent = this;
1106 }
1107
1116 Data & getChild ( size_t index ) {
1117 return m_children [ index ];
1118 }
1119
1128 const Data & getChild ( size_t index ) const {
1129 return m_children [ index ];
1130 }
1131
1139 template < class PositionIterator >
1140 void setChild ( const Data & d, PositionIterator it ) {
1141 m_children.set ( it, d )->parent = this;
1142 }
1143
1151 template < class PositionIterator >
1152 void setChild ( Data && d, PositionIterator it ) {
1153 m_children.set ( it, std::move ( d ) )->parent = this;
1154 }
1155
1163 void setChild ( const Data & d, size_t index ) {
1164 setChild ( d, m_children.begin ( ) + index );
1165 }
1166
1174 void setChild ( Data && d, size_t index ) {
1175 setChild ( std::move ( d ), m_children.begin ( ) + index );
1176 }
1177
1188 return insert ( typename ext::ptr_vector < Data >::const_reverse_iterator ( it ), d );
1189 }
1190
1201 typename ext::ptr_vector < Data >::reverse_iterator iter = m_children.insert ( it, d );
1202
1203 iter->parent = this;
1204
1205 return iter;
1206 }
1207
1218 return insert ( typename ext::ptr_vector < Data >::const_iterator ( it ), d );
1219 }
1220
1231 typename ext::ptr_vector < Data >::iterator iter = m_children.insert ( it, d );
1232
1233 iter->parent = this;
1234
1235 return iter;
1236 }
1237
1248 return insert ( typename ext::ptr_vector < Data >::const_reverse_iterator ( it ), std::move ( d ) );
1249 }
1250
1261 typename ext::ptr_vector < Data >::reverse_iterator iter = m_children.insert ( it, std::move ( d ) );
1262
1263 iter->parent = this;
1264
1265 return iter;
1266 }
1267
1278 return insert ( typename ext::ptr_vector < Data >::const_iterator ( it ), std::move ( d ) );
1279 }
1280
1291 typename ext::ptr_vector < Data >::iterator iter = m_children.insert ( it, std::move ( d ) );
1292
1293 iter->parent = this;
1294
1295 return iter;
1296 }
1297
1310 template < class InputIterator >
1311 typename ext::ptr_vector < Data >::reverse_iterator insert ( typename ext::ptr_vector < Data >::const_reverse_iterator it, InputIterator first, InputIterator last ) {
1312 size_t size = std::distance ( first, last );
1313
1314 typename ext::ptr_vector < Data >::reverse_iterator iter = m_children.insert ( it, first, last );
1315
1316 for ( size_t i = 0; i < size; ++ i ) {
1317 ( iter + i )->parent = this;
1318 }
1319
1320 return iter;
1321 }
1322
1335 template < class InputIterator >
1336 typename ext::ptr_vector < Data >::reverse_iterator insert ( typename ext::ptr_vector < Data >::reverse_iterator it, InputIterator first, InputIterator last ) {
1337 return insert ( typename ext::ptr_vector < Data >::const_reverse_iterator ( it ), first, last );
1338 }
1339
1352 template < class InputIterator >
1353 typename ext::ptr_vector < Data >::iterator insert ( typename ext::ptr_vector < Data >::const_iterator it, InputIterator first, InputIterator last ) {
1354 size_t size = std::distance ( first, last );
1355
1356 typename ext::ptr_vector < Data >::iterator iter = m_children.insert ( it, first, last );
1357
1358 for ( size_t i = 0; i < size; ++ i ) {
1359 ( iter + i )->parent = this;
1360 }
1361
1362 return iter;
1363 }
1364
1377 template < class InputIterator >
1378 typename ext::ptr_vector < Data >::iterator insert ( typename ext::ptr_vector < Data >::iterator it, InputIterator first, InputIterator last ) {
1379 return insert ( typename ext::ptr_vector < Data >::const_iterator ( it ), first, last );
1380 }
1381
1391 return m_children.erase ( typename ext::ptr_vector < Data >::const_reverse_iterator ( it ) );
1392 }
1393
1403 return m_children.erase ( it );
1404 }
1405
1415 return erase ( typename ext::ptr_vector < Data >::const_iterator ( it ) );
1416 }
1417
1427 return m_children.erase ( it );
1428 }
1429
1440 return m_children.erase ( typename ext::ptr_vector < Data >::const_reverse_iterator ( first ), typename ext::ptr_vector < Data >::const_reverse_iterator ( last ) );
1441 }
1442
1453 return m_children.erase ( first, last );
1454 }
1455
1466 return m_children.erase ( typename ext::ptr_vector < Data >::const_iterator ( first ), typename ext::ptr_vector < Data >::const_iterator ( last ) );
1467 }
1468
1479 return m_children.erase ( first, last );
1480 }
1481
1486 void clear ( ) {
1487 m_children.clear ( );
1488 }
1489
1496 void pushBackChild ( const Data & d ) {
1497 m_children.push_back ( d );
1498 m_children [ m_children.size ( ) - 1].parent = this;
1499 }
1500
1507 void pushBackChild ( Data && d ) {
1508 m_children.push_back ( std::move ( d ) );
1509 m_children [ m_children.size ( ) - 1].parent = this;
1510 }
1511
1519 return m_children.begin ( );
1520 }
1521
1529 return m_children.begin ( );
1530 }
1531
1539 return m_children.rbegin ( );
1540 }
1541
1549 return m_children.rbegin ( );
1550 }
1551
1559 return m_children.end ( );
1560 }
1561
1569 return m_children.end ( );
1570 }
1571
1579 return m_children.rend ( );
1580 }
1581
1589 return m_children.rend ( );
1590 }
1591
1592};
1593
1594} /* namespace ext */
1595
Tree node with any but fixed number of children.
Definition: tree_base.hpp:137
AnyaryNode & operator=(const AnyaryNode &other)
Copy operator of assignment.
Definition: tree_base.hpp:188
void setChildren(ext::ptr_array< Data, arity > c)
Setter of the child nodes.
Definition: tree_base.hpp:275
ext::ptr_array< Data, arity >::iterator begin()
Getter of an iterator to the begining of children array.
Definition: tree_base.hpp:314
const Data & getChild() const
Getter of the child node based on compile time index.
Definition: tree_base.hpp:252
const ext::ptr_array< Data, arity > & getChildren() &
Getter of the child nodes.
Definition: tree_base.hpp:219
const ext::ptr_array< Data, arity > & getChildren() const &
Getter of the child nodes.
Definition: tree_base.hpp:229
ext::ptr_array< Data, arity >::const_iterator end() const
Getter of an iterator to the end of children array.
Definition: tree_base.hpp:344
ext::ptr_array< Data, arity >::iterator end()
Getter of an iterator to the end of children array.
Definition: tree_base.hpp:334
AnyaryNode(AnyaryNode &&other) noexcept
Move constructor.
Definition: tree_base.hpp:181
Data & getChild()
Getter of the child node based on compile time index.
Definition: tree_base.hpp:265
void setChild(const Data &d)
Setter of the child node based on compile time index.
Definition: tree_base.hpp:289
AnyaryNode(ext::ptr_array< Data, arity > c)
Constructor based on array of child nodes.
Definition: tree_base.hpp:160
ext::ptr_array< Data, arity > && getChildren() &&
Getter of the child nodes.
Definition: tree_base.hpp:239
ext::ptr_array< Data, arity >::const_iterator begin() const
Getter of an iterator to the begining of children array.
Definition: tree_base.hpp:324
void setChild(Data &&d)
Setter of the child node based on compile time index.
Definition: tree_base.hpp:303
~AnyaryNode() noexcept override=default
Destructor of the class.
Base class for hierarchy of tree node types. The tree node types can be used to construct tree struct...
Definition: tree_base.hpp:20
BaseNode & operator=(const BaseNode &)
Copy assignment does not change the parent pointer.
Definition: tree_base.hpp:94
const Data * getParent() const
Getter of the parent of the node.
Definition: tree_base.hpp:122
Data * getParent()
Getter of the parent of the node.
Definition: tree_base.hpp:112
BaseNode(BaseNode &&) noexcept
Move construction does not copy the parent pointer.
Definition: tree_base.hpp:87
BaseNode()
Constructor of the tree hierarchy base class.
Definition: tree_base.hpp:67
virtual ~BaseNode() noexcept=default
Destructor of the tree hierarchy base class.
Binary node is specialisation of Anyary node to two children.
Definition: tree_base.hpp:459
void setLeft(Data &&l)
Setter of the first child of the node.
Definition: tree_base.hpp:517
void setRight(Data &&r)
Setter of the second child of the node.
Definition: tree_base.hpp:557
void setRight(const Data &r)
Setter of the second child of the node.
Definition: tree_base.hpp:547
const Data & getLeft() const
Getter of the first child of the node.
Definition: tree_base.hpp:497
BinaryNode(const Data &l, const Data &r)
Constructor of the class accepting the two child nodes.
Definition: tree_base.hpp:468
Data & getLeft()
Getter of the first child of the node.
Definition: tree_base.hpp:487
Data & getRight()
Getter of the second child of the node.
Definition: tree_base.hpp:527
const Data & getRight() const
Getter of the second child of the node.
Definition: tree_base.hpp:537
BinaryNode(Data &&l, Data &&r)
Constructor of the class accepting the two child nodes.
Definition: tree_base.hpp:478
void setLeft(const Data &l)
Setter of the first child of the node.
Definition: tree_base.hpp:507
Fixedary node is tree node that when initialized does not permit change of the number of its children...
Definition: tree_base.hpp:725
const ext::ptr_vector< Data > & getChildren() &
Getter of the vector of children.
Definition: tree_base.hpp:821
FixedaryNode(ext::ptr_vector< Data > c)
Constructor of the node from vector of children.
Definition: tree_base.hpp:739
ext::ptr_vector< Data > && getChildren() &&
Getter of the child nodes.
Definition: tree_base.hpp:841
FixedaryNode(Types &&... data)
Constructor of the node from pack of children.
Definition: tree_base.hpp:753
void setChildren(ext::ptr_vector< Data > c)
Setter of the vector of children.
Definition: tree_base.hpp:851
ext::ptr_vector< Data >::iterator end()
Getter of an iterator to the end of children vector.
Definition: tree_base.hpp:957
void setChild(Data &&d, size_t index)
Setter of the single child of the node.
Definition: tree_base.hpp:927
ext::ptr_vector< Data >::iterator begin()
Getter of an iterator to the begining of children vector.
Definition: tree_base.hpp:937
void setChild(const Data &d, size_t index)
Setter of the single child of the node.
Definition: tree_base.hpp:916
void setChild(Data &&d, PositionIterator it)
Setter of the single child of the node.
Definition: tree_base.hpp:893
FixedaryNode(FixedaryNode &&other) noexcept
Move constructor of the class.
Definition: tree_base.hpp:777
ext::ptr_vector< Data >::const_iterator end() const
Getter of an iterator to the end of children vector.
Definition: tree_base.hpp:967
Data & getChild(size_t index)
Getter of the child at given index.
Definition: tree_base.hpp:869
const Data & getChild(size_t index) const
Getter of the child at given index.
Definition: tree_base.hpp:881
~FixedaryNode() noexcept override=default
Destructor of the class.
ext::ptr_vector< Data >::const_iterator begin() const
Getter of an iterator to the begining of children vector.
Definition: tree_base.hpp:947
const ext::ptr_vector< Data > & getChildren() const &
Getter of the vector of children.
Definition: tree_base.hpp:831
void setChild(const Data &d, PositionIterator it)
Setter of the single child of the node.
Definition: tree_base.hpp:905
Nullary node is specialisation of Anyary node to no children.
Definition: tree_base.hpp:358
NullaryNode()
The default constructor of the class.
Definition: tree_base.hpp:364
Ternany node is specialisation of Anyary node to three children.
Definition: tree_base.hpp:571
Data & getFirst()
Getter of the first child of the node.
Definition: tree_base.hpp:601
TernaryNode(Data &&f, Data &&s, Data &&t)
Constructor of the class accepting the three child nodes.
Definition: tree_base.hpp:592
void setSecond(Data &&s)
Setter of the second child of the node.
Definition: tree_base.hpp:671
void setFirst(Data &&f)
Setter of the first child of the node.
Definition: tree_base.hpp:631
void setThird(Data &&t)
Setter of the third child of the node.
Definition: tree_base.hpp:711
const Data & getFirst() const
Getter of the first child of the node.
Definition: tree_base.hpp:611
const Data & getSecond() const
Getter of the second child of the node.
Definition: tree_base.hpp:651
void setFirst(const Data &f)
Setter of the first child of the node.
Definition: tree_base.hpp:621
TernaryNode(const Data &f, const Data &s, const Data &t)
Constructor of the class accepting the three child nodes.
Definition: tree_base.hpp:581
const Data & getThird() const
Getter of the third child of the node.
Definition: tree_base.hpp:691
Data & getSecond()
Getter of the second child of the node.
Definition: tree_base.hpp:641
void setThird(const Data &t)
Setter of the third child of the node.
Definition: tree_base.hpp:701
void setSecond(const Data &s)
Setter of the second child of the node.
Definition: tree_base.hpp:661
Data & getThird()
Getter of the third child of the node.
Definition: tree_base.hpp:681
Unary node is specialisation of Anyary node to one child.
Definition: tree_base.hpp:377
UnaryNode(Data &&c)
Constructor of the class accepting the child node.
Definition: tree_base.hpp:394
Data & getChild()
Getter of the child of the node.
Definition: tree_base.hpp:403
void setChild(const Data &c)
Setter of the child of the node.
Definition: tree_base.hpp:429
const Data & getChild() const
Getter of the child of the node.
Definition: tree_base.hpp:413
void setChild(Data &&c)
Setter of the child of the node.
Definition: tree_base.hpp:439
UnaryNode(const Data &c)
Constructor of the class accepting the child node.
Definition: tree_base.hpp:385
Varary node is tree node that can hold any number of children.
Definition: tree_base.hpp:981
void pushBackChild(const Data &d)
Appends a new child at the end of the child vector.
Definition: tree_base.hpp:1496
ext::ptr_vector< Data >::iterator insert(typename ext::ptr_vector< Data >::const_iterator it, InputIterator first, InputIterator last)
Inserts a new children from a given range at position specified by iterator.
Definition: tree_base.hpp:1353
const ext::ptr_vector< Data > & getChildren() const &
Getter of the vector of children.
Definition: tree_base.hpp:1081
ext::ptr_vector< Data >::const_reverse_iterator rend() const
Getter of an iterator to the end of children vector.
Definition: tree_base.hpp:1588
ext::ptr_vector< Data >::reverse_iterator insert(typename ext::ptr_vector< Data >::const_reverse_iterator it, const Data &d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1200
VararyNode(ext::ptr_vector< Data > c)
Constructor from vector of child nodes.
Definition: tree_base.hpp:1001
void pushBackChild(Data &&d)
Appends a new child at the end of the child vector.
Definition: tree_base.hpp:1507
ext::ptr_vector< Data >::reverse_iterator erase(typename ext::ptr_vector< Data >::const_reverse_iterator first, typename ext::ptr_vector< Data >::const_reverse_iterator last)
Erases a range of children specified by an iterator.
Definition: tree_base.hpp:1452
VararyNode()=default
Default constructor. Sets the vector of children to empty vector.
ext::ptr_vector< Data >::const_iterator end() const
Getter of an iterator to the end of children vector.
Definition: tree_base.hpp:1568
ext::ptr_vector< Data >::iterator erase(typename ext::ptr_vector< Data >::iterator first, typename ext::ptr_vector< Data >::iterator last)
Erases a range of children specified by an iterator.
Definition: tree_base.hpp:1465
ext::ptr_vector< Data >::const_reverse_iterator rbegin() const
Getter of an iterator to the begining of children vector.
Definition: tree_base.hpp:1548
VararyNode & operator=(const VararyNode &other)
Copy operator of assignment.
Definition: tree_base.hpp:1036
ext::ptr_vector< Data >::iterator insert(typename ext::ptr_vector< Data >::const_iterator it, const Data &d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1230
ext::ptr_vector< Data >::reverse_iterator erase(typename ext::ptr_vector< Data >::reverse_iterator it)
Erases a child specified by an iterator.
Definition: tree_base.hpp:1390
ext::ptr_vector< Data >::reverse_iterator insert(typename ext::ptr_vector< Data >::reverse_iterator it, const Data &d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1187
ext::ptr_vector< Data >::reverse_iterator insert(typename ext::ptr_vector< Data >::reverse_iterator it, Data &&d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1247
ext::ptr_vector< Data >::iterator insert(typename ext::ptr_vector< Data >::const_iterator it, Data &&d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1290
void setChild(const Data &d, size_t index)
Setter of the single child of the node.
Definition: tree_base.hpp:1163
~VararyNode() noexcept override=default
Destructor of the class.
ext::ptr_vector< Data > && getChildren() &&
Getter of the child nodes.
Definition: tree_base.hpp:1091
ext::ptr_vector< Data >::iterator insert(typename ext::ptr_vector< Data >::iterator it, InputIterator first, InputIterator last)
Inserts a new children from a given range at position specified by iterator.
Definition: tree_base.hpp:1378
ext::ptr_vector< Data >::iterator end()
Getter of an iterator to the end of children vector.
Definition: tree_base.hpp:1558
ext::ptr_vector< Data >::reverse_iterator rbegin()
Getter of an iterator to the begining of children vector.
Definition: tree_base.hpp:1538
void setChildren(ext::ptr_vector< Data > c)
Setter of the vector of children.
Definition: tree_base.hpp:1101
ext::ptr_vector< Data >::reverse_iterator insert(typename ext::ptr_vector< Data >::reverse_iterator it, InputIterator first, InputIterator last)
Inserts a new children from a given range at position specified by iterator.
Definition: tree_base.hpp:1336
const ext::ptr_vector< Data > & getChildren() &
Getter of the vector of children.
Definition: tree_base.hpp:1071
const Data & getChild(size_t index) const
Getter of the child at given index.
Definition: tree_base.hpp:1128
ext::ptr_vector< Data >::reverse_iterator rend()
Getter of an iterator to the end of children vector.
Definition: tree_base.hpp:1578
ext::ptr_vector< Data >::const_iterator begin() const
Getter of an iterator to the begining of children vector.
Definition: tree_base.hpp:1528
ext::ptr_vector< Data >::reverse_iterator insert(typename ext::ptr_vector< Data >::const_reverse_iterator it, InputIterator first, InputIterator last)
Inserts a new children from a given range at position specified by iterator.
Definition: tree_base.hpp:1311
ext::ptr_vector< Data >::iterator erase(typename ext::ptr_vector< Data >::const_iterator first, typename ext::ptr_vector< Data >::const_iterator last)
Erases a range of children specified by an iterator.
Definition: tree_base.hpp:1478
ext::ptr_vector< Data >::iterator insert(typename ext::ptr_vector< Data >::iterator it, Data &&d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1277
ext::ptr_vector< Data >::reverse_iterator erase(typename ext::ptr_vector< Data >::const_reverse_iterator it)
Erases a child specified by an iterator.
Definition: tree_base.hpp:1402
void setChild(Data &&d, PositionIterator it)
Setter of the single child of the node.
Definition: tree_base.hpp:1152
ext::ptr_vector< Data >::iterator insert(typename ext::ptr_vector< Data >::iterator it, const Data &d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1217
void clear()
Erases all children.
Definition: tree_base.hpp:1486
Data & getChild(size_t index)
Getter of the child at given index.
Definition: tree_base.hpp:1116
ext::ptr_vector< Data >::iterator erase(typename ext::ptr_vector< Data >::iterator it)
Erases a child specified by an iterator.
Definition: tree_base.hpp:1414
void setChild(const Data &d, PositionIterator it)
Setter of the single child of the node.
Definition: tree_base.hpp:1140
void setChild(Data &&d, size_t index)
Setter of the single child of the node.
Definition: tree_base.hpp:1174
VararyNode(VararyNode &&other) noexcept
Move constructor of the class.
Definition: tree_base.hpp:1027
ext::ptr_vector< Data >::reverse_iterator erase(typename ext::ptr_vector< Data >::reverse_iterator first, typename ext::ptr_vector< Data >::reverse_iterator last)
Erases a range of children specified by an iterator.
Definition: tree_base.hpp:1439
ext::ptr_vector< Data >::reverse_iterator insert(typename ext::ptr_vector< Data >::const_reverse_iterator it, Data &&d)
Inserts a new child at position specified by iterator.
Definition: tree_base.hpp:1260
ext::ptr_vector< Data >::iterator begin()
Getter of an iterator to the begining of children vector.
Definition: tree_base.hpp:1518
ext::ptr_vector< Data >::iterator erase(typename ext::ptr_vector< Data >::const_iterator it)
Erases a child specified by an iterator.
Definition: tree_base.hpp:1426
Adaptor iterator to additionally call second dereference on the iterator dereference result.
Definition: iterator.hpp:556
Implementation of array storing dynamicaly allocated instances of given type. The class mimicks the i...
Definition: ptr_array.hpp:45
iterator set(const_iterator pos, R &&value)
Setter of value in the array on position specified by iterator specified by pos. The value is cloned ...
Definition: ptr_array.hpp:540
iterator begin() &noexcept
Iterator to the begining of the values range in the array.
Definition: ptr_array.hpp:328
iterator end() &noexcept
Iterator one past the last element of the values range in the array.
Definition: ptr_array.hpp:368
const_iterator cbegin() const noexcept
Iterator to the begining of the values range in the array.
Definition: ptr_array.hpp:358
size_type size() const noexcept
Getter of the array size.
Definition: ptr_array.hpp:514
Implementation of vector storing dynamicaly allocated instances of given type. The class mimicks the ...
Definition: ptr_vector.hpp:44
iterator end() &noexcept
Iterator one past the last element of the values range in the vector.
Definition: ptr_vector.hpp:422
void push_back(R &&value)
Appends a new value at the end of the container.
Definition: ptr_vector.hpp:1228
reverse_iterator rend() noexcept
Reverse iterator one past the last element of the reversed range of values in the vector.
Definition: ptr_vector.hpp:492
iterator begin() &noexcept
Iterator to the begining of the values range in the vector.
Definition: ptr_vector.hpp:382
reverse_iterator rbegin() noexcept
Reverse iterator to the begining of the reversed range of values in the vector.
Definition: ptr_vector.hpp:462
size_type size() const noexcept
Getter of the vector size.
Definition: ptr_vector.hpp:568
iterator erase(iterator pos)
Removes element from the container at position given by parameter pos.
Definition: ptr_vector.hpp:1119
void clear() noexcept
Removes all values from the vector.
Definition: ptr_vector.hpp:614
iterator set(iterator pos, R &&value)
Changes the value on position given by iterator pos.
Definition: ptr_vector.hpp:633
iterator insert(iterator pos, R &&value)
Inserts the value on position given by iterator pos.
Definition: ptr_vector.hpp:775
int i
Definition: AllEpsilonClosure.h:118
Definition: sigHandler.cpp:20
constexpr ptr_array< typename std::remove_reference< Base >::type, sizeof ...(Types)+1 > make_ptr_array(Base &&first, Types &&... other)
Array construction helper. Array is constructed from provided values, type of stored elements is dedu...
Definition: ptr_array.hpp:775
void swap(ext::linear_set< T, Compare, Alloc > &x, ext::linear_set< T, Compare, Alloc > &y)
Specialisation of swap for linear set.
Definition: linear_set.hpp:846
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