35#ifndef __ADS_PreorderArrayTree
36 #define __ADS_PreorderArrayTree
68 static constexpr int NIL = -1;
77 [[nodiscard]]
bool empty(
void )
const;
80 [[nodiscard]]
int size(
void )
const;
83 [[nodiscard]]
int root(
void )
const;
87 [[nodiscard]]
int parent(
int i )
const;
91 [[nodiscard]]
const T &
read(
int i )
const;
95 void write(
int i ,
const T & v );
109 [[nodiscard]]
bool isLeaf(
int i )
const;
186 const Cell & cell(
int i )
const;
189 [[nodiscard]]
bool preordered(
void )
const;
196 std::vector< Cell > f_A;
208#include "ADS/tree/impl/PreorderArrayTree.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
an ordered tree in a vector of ( parent , value ) in preorder
Definition PreorderArrayTree.h:63
T Item
the type of the values
Definition PreorderArrayTree.h:67
int subtreeEnd(int i) const
the place after the subtree of
void write(int i, const T &v)
writes in
PreorderArrayTree(const T &v)
a tree of one node of value
bool empty(void) const
true if the tree has no node
auto values(void) const
the values of the nodes in preorder, which is the order of the array, random access
void insertChild(int i, const PreorderArrayTree &t)
a copy of as the first child of ; may be this tree, copied as it was before the call
void insertSibling(int i, const PreorderArrayTree &t)
a copy of as the next sibling of , not the root; may be this tree, copied as it was before the call...
static constexpr int NIL
no node
Definition PreorderArrayTree.h:68
int parent(int i) const
the parent of , NIL for the root
int root(void) const
the root, 0, or NIL if the tree is empty
int rightSibling(int i) const
the next sibling, the place after the subtree of if it has the same parent, NIL otherwise
int leftmostChild(int i) const
the first child, if its parent is , NIL otherwise
bool isLeaf(int i) const
true if has no child
void remove(int i)
removes the subtree of , the places after it shifted back and their parents renumbered
PreorderArrayTree(void)=default
the empty tree
const T & read(int i) const
the value of
int size(void) const
the number of nodes,