|
ADS
Algorithms and Data Structures
|
A binary tree with cursors, beyond the book: the nodes in a vector, each with its value and the places of its parent and of its two children, NIL if missing, so that the links are indices instead of pointers and the tree can be copied, saved or moved as a whole. More...
#include "ADS/Contract.h"#include "ADS/Iterators.h"#include <cstddef>#include <ranges>#include <stdexcept>#include <string>#include <utility>#include <vector>#include "ADS/tree/impl/CursorBinaryTree.tpp"Go to the source code of this file.
Classes | |
| class | ADS::CursorBinaryTree< T > |
| a binary tree on a vector of nodes linked by their places More... | |
| struct | ADS::CursorBinaryTree< T >::Used |
| the places in use, for SlotIterator More... | |
Namespaces | |
| namespace | ADS |
A binary tree with cursors, beyond the book: the nodes in a vector, each with its value and the places of its parent and of its two children, NIL if missing, so that the links are indices instead of pointers and the tree can be copied, saved or moved as a whole.
A removed subtree returns its places to a free list, which the next insertions reuse. Moving along the tree, reading, writing and inserting a node take \( O( 1 ) \) amortized time; removing or copying a subtree takes time linear in its size.
The contracts [see Contract.h]: a node is a used place, setRoot() needs an empty tree, a child is inserted where none is, and the subtree copied is a node of the other tree; the invariant is that the nodes reached from the root link back to their parent and are all the nodes. The operations are defined in CursorBinaryTree.tpp.