carl
24.04
Computer ARithmetic Library
|
This class represents a tree. More...
#include <carlTree.h>
Public Types | |
using | value_type = T |
using | Node = tree_detail::Node< T > |
template<bool reverse> | |
using | PreorderIterator = tree_detail::PreorderIterator< T, reverse > |
template<bool reverse> | |
using | PostorderIterator = tree_detail::PostorderIterator< T, reverse > |
template<bool reverse> | |
using | LeafIterator = tree_detail::LeafIterator< T, reverse > |
template<bool reverse> | |
using | DepthIterator = tree_detail::DepthIterator< T, reverse > |
template<bool reverse> | |
using | ChildrenIterator = tree_detail::ChildrenIterator< T, reverse > |
using | PathIterator = tree_detail::PathIterator< T > |
using | iterator = PreorderIterator< false > |
Public Member Functions | |
tree ()=default | |
tree (const tree &t)=default | |
tree (tree &&t) noexcept=default | |
tree & | operator= (const tree &t)=default |
tree & | operator= (tree &&t) noexcept=default |
void | debug () const |
iterator | begin () const |
iterator | end () const |
iterator | rbegin () const |
iterator | rend () const |
PreorderIterator< false > | begin_preorder () const |
PreorderIterator< false > | end_preorder () const |
PreorderIterator< true > | rbegin_preorder () const |
PreorderIterator< true > | rend_preorder () const |
PostorderIterator< false > | begin_postorder () const |
PostorderIterator< false > | end_postorder () const |
PostorderIterator< true > | rbegin_postorder () const |
PostorderIterator< true > | rend_postorder () const |
LeafIterator< false > | begin_leaf () const |
LeafIterator< false > | end_leaf () const |
LeafIterator< true > | rbegin_leaf () const |
LeafIterator< true > | rend_leaf () const |
DepthIterator< false > | begin_depth (std::size_t depth) const |
DepthIterator< false > | end_depth () const |
DepthIterator< true > | rbegin_depth (std::size_t depth) const |
DepthIterator< true > | rend_depth () const |
template<typename Iterator > | |
ChildrenIterator< false > | begin_children (const Iterator &it) const |
template<typename Iterator > | |
ChildrenIterator< false > | end_children (const Iterator &it) const |
template<typename Iterator > | |
ChildrenIterator< true > | rbegin_children (const Iterator &it) const |
template<typename Iterator > | |
ChildrenIterator< true > | rend_children (const Iterator &it) const |
template<typename Iterator > | |
PathIterator | begin_path (const Iterator &it) const |
PathIterator | end_path () const |
std::size_t | max_depth () const |
Retrieves the maximum depth of all elements. More... | |
template<typename Iterator > | |
std::size_t | max_depth (const Iterator &it) const |
template<typename Iterator > | |
bool | is_leaf (const Iterator &it) const |
Check if the given element is a leaf. More... | |
template<typename Iterator > | |
bool | is_leftmost (const Iterator &it) const |
Check if the given element is a leftmost child. More... | |
template<typename Iterator > | |
bool | is_rightmost (const Iterator &it) const |
Check if the given element is a rightmost child. More... | |
template<typename Iterator > | |
bool | is_valid (const Iterator &it) const |
template<typename Iterator > | |
Iterator | get_parent (const Iterator &it) const |
Retrieves the parent of an element. More... | |
template<typename Iterator > | |
Iterator | left_sibling (const Iterator &it) const |
iterator | setRoot (const T &data) |
Sets the value of the root element. More... | |
iterator | setRoot (T &&data) |
void | clear () |
Clears the tree. More... | |
iterator | append (const T &data) |
Add the given data as last child of the root element. More... | |
template<typename Iterator > | |
Iterator | append (Iterator parent, const T &data) |
Add the given data as last child of the given element. More... | |
template<typename Iterator > | |
Iterator | insert (Iterator position, const T &data) |
Insert element before the given position. More... | |
iterator | append (tree &&tree) |
Append another tree as last child of the root element. More... | |
template<typename Iterator > | |
Iterator | append (Iterator position, tree &&data) |
Append another tree as last child of the given element. More... | |
template<typename Iterator > | |
const Iterator & | replace (const Iterator &position, const T &data) |
template<typename Iterator > | |
Iterator | erase (Iterator position) |
Erase the element at the given position. More... | |
template<typename Iterator > | |
void | eraseChildren (const Iterator &position) |
Erase all children of the given element. More... | |
bool | is_consistent () const |
bool | is_consistent (std::size_t node) const |
Private Member Functions | |
std::size_t | newNode (T &&data, std::size_t parent, std::size_t depth) |
std::size_t | createNode (const T &data, std::size_t parent, std::size_t depth) |
void | eraseChildren (std::size_t id) |
void | eraseNode (std::size_t id) |
Private Attributes | |
std::vector< Node > | nodes |
std::size_t | emptyNodes = MAXINT |
Static Private Attributes | |
static constexpr std::size_t | MAXINT = tree_detail::MAXINT |
Friends | |
template<typename TT , typename Iterator , bool reverse> | |
struct | tree_detail::BaseIterator |
This class represents a tree.
It tries to stick to the STL style as close as possible.
Definition at line 559 of file carlTree.h.
using carl::tree< T >::ChildrenIterator = tree_detail::ChildrenIterator<T,reverse> |
Definition at line 573 of file carlTree.h.
using carl::tree< T >::DepthIterator = tree_detail::DepthIterator<T,reverse> |
Definition at line 571 of file carlTree.h.
using carl::tree< T >::iterator = PreorderIterator<false> |
Definition at line 584 of file carlTree.h.
using carl::tree< T >::LeafIterator = tree_detail::LeafIterator<T,reverse> |
Definition at line 569 of file carlTree.h.
using carl::tree< T >::Node = tree_detail::Node<T> |
Definition at line 562 of file carlTree.h.
using carl::tree< T >::PathIterator = tree_detail::PathIterator<T> |
Definition at line 574 of file carlTree.h.
using carl::tree< T >::PostorderIterator = tree_detail::PostorderIterator<T,reverse> |
Definition at line 567 of file carlTree.h.
using carl::tree< T >::PreorderIterator = tree_detail::PreorderIterator<T,reverse> |
Definition at line 565 of file carlTree.h.
using carl::tree< T >::value_type = T |
Definition at line 561 of file carlTree.h.
|
default |
|
default |
|
defaultnoexcept |
|
inline |
Add the given data as last child of the root element.
data | Data. |
Definition at line 785 of file carlTree.h.
|
inline |
Add the given data as last child of the given element.
parent | Parent element. |
data | Data. |
Definition at line 797 of file carlTree.h.
|
inline |
Append another tree as last child of the given element.
position | Element. |
tree | Tree. |
Definition at line 847 of file carlTree.h.
|
inline |
Append another tree as last child of the root element.
tree | Tree. |
Definition at line 836 of file carlTree.h.
|
inline |
Definition at line 597 of file carlTree.h.
|
inline |
Definition at line 667 of file carlTree.h.
|
inline |
|
inline |
|
inline |
Definition at line 683 of file carlTree.h.
|
inline |
|
inline |
|
inline |
Clears the tree.
Definition at line 776 of file carlTree.h.
|
inlineprivate |
|
inline |
Definition at line 592 of file carlTree.h.
|
inline |
Definition at line 600 of file carlTree.h.
|
inline |
Definition at line 671 of file carlTree.h.
|
inline |
Definition at line 657 of file carlTree.h.
|
inline |
Definition at line 643 of file carlTree.h.
|
inline |
Definition at line 686 of file carlTree.h.
|
inline |
Definition at line 629 of file carlTree.h.
|
inline |
|
inline |
Erase the element at the given position.
Returns an iterator to the next position.
position | Element. |
Definition at line 873 of file carlTree.h.
|
inline |
Erase all children of the given element.
position | Element. |
Definition at line 901 of file carlTree.h.
|
inlineprivate |
|
inlineprivate |
|
inline |
Retrieves the parent of an element.
it | Iterator. |
it
. Definition at line 749 of file carlTree.h.
|
inline |
Insert element before the given position.
position | Position to insert before. |
data | Element to insert. |
Definition at line 810 of file carlTree.h.
|
inline |
Definition at line 954 of file carlTree.h.
|
inline |
|
inline |
Check if the given element is a leaf.
it | Iterator. |
it
is a leaf. Definition at line 717 of file carlTree.h.
|
inline |
Check if the given element is a leftmost child.
it | Iterator. |
it
is a leftmost child. Definition at line 726 of file carlTree.h.
|
inline |
Check if the given element is a rightmost child.
it | Iterator. |
it
is a rightmost child. Definition at line 735 of file carlTree.h.
|
inline |
|
inline |
|
inline |
Retrieves the maximum depth of all elements.
Definition at line 694 of file carlTree.h.
|
inline |
Definition at line 702 of file carlTree.h.
|
inlineprivate |
|
default |
|
defaultnoexcept |
|
inline |
Definition at line 603 of file carlTree.h.
|
inline |
Definition at line 675 of file carlTree.h.
|
inline |
|
inline |
|
inline |
Definition at line 632 of file carlTree.h.
|
inline |
|
inline |
Definition at line 606 of file carlTree.h.
|
inline |
Definition at line 679 of file carlTree.h.
|
inline |
Definition at line 663 of file carlTree.h.
|
inline |
Definition at line 651 of file carlTree.h.
|
inline |
Definition at line 635 of file carlTree.h.
|
inline |
Definition at line 621 of file carlTree.h.
|
inline |
|
inline |
Sets the value of the root element.
data | Data. |
Definition at line 765 of file carlTree.h.
|
inline |
|
friend |
Definition at line 577 of file carlTree.h.
|
private |
Definition at line 581 of file carlTree.h.
|
staticconstexprprivate |
Definition at line 579 of file carlTree.h.
|
private |
Definition at line 580 of file carlTree.h.