|
fennec
|
Structure defining a binary tree. More...
#include <bintree.h>
| TypeT | The data type |
| AllocT | An allocator class |
Public Member Functions | |
| constexpr size_t | size () const |
| constexpr bool | empty () const |
| constexpr size_t | capacity () const |
| constexpr size_t | next_id () const |
| constexpr size_t | root () const |
| template<typename OrderT , typename VisitorT > | |
| constexpr void | traverse (VisitorT &&visit, size_t i) |
| Traverse the tree using a specified order and visiting functor. | |
Constructors & Destructor | |
| constexpr | bintree () |
| Default Constructor, initializes an empty tree. | |
| constexpr | bintree (bintree &&tree) noexcept |
| Move Constructor, takes ownership of a tree. | |
| constexpr | bintree (const bintree &tree) |
| Copy Constructor, copies a tree. | |
| constexpr | ~bintree () |
| Destructor, clears the tree. | |
Navigation | |
| constexpr size_t | parent (size_t i) const |
| constexpr size_t | grandparent (size_t i) const |
| constexpr size_t | left (size_t i) const |
| constexpr size_t | right (size_t i) const |
| constexpr size_t | child (size_t i, bool dir) const |
| constexpr bool | direction (size_t i) const |
| constexpr size_t | sibling (size_t i) const |
| \(O(1)\) | |
| constexpr size_t | depth (size_t i) const |
| constexpr size_t | left_most (size_t i) const |
| \(O(\log n)\) | |
| constexpr size_t | right_most (size_t i) const |
| \(O(\log n)\) | |
Access | |
| constexpr value_t & | operator[] (size_t i) |
| constexpr const value_t & | operator[] (size_t i) const |
Modifiers | |
| constexpr size_t | insert_left (size_t p, value_t &&val) |
Move Left Insertion, constructs a new node as the left child of p | |
| constexpr size_t | insert_left (size_t p, const value_t &val) |
Copy Left Insertion, constructs a new node as the left child of p | |
| template<typename... ArgsT> | |
| constexpr size_t | emplace_left (size_t p, ArgsT &&...args) |
Emplace Left Insertion, constructs a new node as the left child of p | |
| constexpr size_t | insert_right (size_t p, value_t &&val) |
Move Right Insertion, constructs a new node as the right child of p | |
| constexpr size_t | insert_right (size_t p, const value_t &val) |
Copy Right Insertion, constructs a new node as the right child of p | |
| template<typename... ArgsT> | |
| constexpr size_t | emplace_right (size_t p, ArgsT &&...args) |
Emplace Right Insertion, constructs a new node as the right child of p | |
| constexpr size_t | rotate (size_t sub, bool dir) |
Perform a Tree Rotation at i in the specified direction. | |
| constexpr size_t | insert (size_t p, bool d, value_t &&val) |
Move Insertion, bool d, constructs a new node as the child of p | |
| constexpr size_t | insert (size_t p, bool d, const value_t &val) |
Copy Insertion, bool d, constructs a new node as the child of p | |
| template<typename... ArgsT> | |
| constexpr size_t | emplace (size_t p, bool d, ArgsT &&...args) |
Emplace Insertion, constructs a new node as the child of p | |
| constexpr void | clear () |
| Clears the tree, destroying all elements. | |
|
inlineconstexprnoexcept |
| tree | The tree to take ownership of |
|
inlineconstexpr |
| tree | The tree to copy |
|
inlineconstexpr |
|
inlineconstexpr |
true when there are no elements in the tree, false otherwise.
|
inlineconstexpr |
|
inlineconstexpr |
insert or emplace.
|
inlineconstexpr |
insert or emplace.
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
i
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
i
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
i
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
i
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
| dir | The direction to go true for right, false for left |
dir
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
true if i is the right node of parent(i), false otherwise
|
inlineconstexpr |
| i | The id of the node |
i
|
inlineconstexpr |
\(O(\log n)\)
| i | The node id |
i
|
inlineconstexpr |
| i | The node id |
i
|
inlineconstexpr |
| i | The node id |
i
|
inlineconstexpr |
\(O(1)\)
| i | The node id |
nullptr if node i does not exist, otherwise, a pointer to the value of node i
|
inlineconstexpr |
Const Access, \(O(1)\)
| i | The node id |
nullptr if node i does not exist, otherwise, a pointer to the value of node i
|
inlineconstexpr |
If the left node of p already exists, the move assignment operator is used instead
| p | The parent node |
| val | The object to move into the new node |
|
inlineconstexpr |
If the left node of p already exists, the copy assignment operator is used instead
| p | The parent node |
| val | The object to copy to the new node |
|
inlineconstexpr |
If the left node of p already exists, the move assignment operator is used instead
| p | The parent node |
| args | The arguments to construct the new node with |
|
inlineconstexpr |
If the right node of p already exists, the move assignment operator is used instead
| p | The parent node |
| val | The object to move into the new node |
|
inlineconstexpr |
If the right node of p already exists, the copy assignment operator is used instead
| p | The parent node |
| val | The object to copy to the new node |
|
inlineconstexpr |
If the right node of p already exists, the move assignment operator is used instead
| p | The parent node |
| args | The arguments to construct the new node with |
|
inlineconstexpr |
| i | The root node for the rotation |
| dir | The direction to rotate, true for right, false for left |
|
inlineconstexpr |
If the child of p already exists, the move assignment operator is used instead
| p | The parent node |
| d | The direction to insert |
| val | The object to move into the new node |
|
inlineconstexpr |
If the child of p already exists, the copy assignment operator is used instead
| p | The parent node |
| d | The direction to insert |
| val | The object to copy to the new node |
|
inlineconstexpr |
If the child of p already exists, the move assignment operator is used instead
| p | The parent node |
| d | The direction to insert |
| args | The arguments to construct the new node with |
|
inlineconstexpr |
The visitor should accept a reference to a value of type TypeT and a size_t which contains the node's id. The visitor should return one of the following values in the fennec::traversal_control_ enum
| OrderT | The order with which to traverse the tree. |
| VisitorT | The visitor, should fulfill the signature uint8_t visit(TypeT&, size_t) |
| visit | The visiting object |
| i | The node to start at |