39#ifndef __ADS_ChildListTree
40 #define __ADS_ChildListTree
72 static constexpr int NIL = -1;
94 [[nodiscard]]
bool empty(
void )
const;
97 [[nodiscard]]
int root(
void )
const;
114 [[nodiscard]]
bool isLeaf(
int n )
const;
126 [[nodiscard]]
const T &
read(
int n )
const;
133 [[nodiscard]]
int size(
void )
const;
196 [[nodiscard]] std::vector< int >
previsit(
void )
const;
199 [[nodiscard]] std::vector< int >
postvisit(
void )
const;
203 [[nodiscard]] std::vector< int >
invisit(
int i )
const;
217 const Node & node(
int n )
const;
218 Node & node(
int n );
222 int make(
const T & v ,
int p );
229 void release(
int n );
233 void visit(
int n ,
int i , std::vector< int > & P ,
int kind )
const;
237 [[nodiscard]]
bool linked(
void )
const;
239 std::vector< Node > f_N;
254#include "ADS/tree/impl/ChildListTree.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The LIST of the book: a SEQUENCE [see ADT.h] realized as a bidirectional circular list of cells with ...
an ordered tree whose nodes keep the list of their children
Definition ChildListTree.h:67
ChildListTree(void)=default
the empty tree
int root(void) const
the place of the root, NIL if the tree is empty
bool isLastSibling(int n) const
whether is the last of its siblings
static constexpr int NIL
no node
Definition ChildListTree.h:72
int rightSibling(int n) const
the next sibling of , the next cell of the list of its parent, NIL if there is none
int insertSibling(int n, const T &v)
a new next sibling of , not the root, of value , in : as insertChild() on the list of the parent of ,...
int insertChildTree(int n, const ChildListTree &t, int s)
a copy of the subtree of in as the first child of , in for the nodes of the subtree; may be this...
std::vector< int > previsit(void) const
the nodes in previsit
void write(int n, const T &v)
writes in
ChildListTree & operator=(const ChildListTree &o)
a copy of o, as the copy constructor
bool isLeaf(int n) const
true if has no child
int leftmostChild(int n) const
the first child of , the head of its list, NIL for a leaf
int insertChild(int n, const T &v)
a new first child of of value , in
int insertSiblingTree(int n, const ChildListTree &t, int s)
a copy of the subtree of in as the next sibling of , as insertChildTree() after the cell of ; may ...
std::vector< int > invisit(int i) const
the nodes in invisit with index , as CursorTree::invisit() on the lists of the children
void remove(int n)
removes the subtree of , detached from its parent in by the position of its cell,...
ChildListTree & operator=(ChildListTree &&o) noexcept=default
the nodes of o, with their lists and cells
const List< int > & children(int n) const
the list of the children of , in their order
T Item
the type of the values
Definition ChildListTree.h:71
ChildListTree(const ChildListTree &o)
a copy of o, whose nodes keep the positions of their cells in the new lists, not in those of o,...
int parent(int n) const
the parent of , NIL for the root
bool empty(void) const
true if the tree has no node
int size(void) const
the number of nodes
std::vector< int > postvisit(void) const
the nodes in postvisit
const T & read(int n) const
the value of
ChildListTree(ChildListTree &&o) noexcept=default
the nodes of o, with their lists and cells
ChildListTree(const T &v)
a tree of one node of value
Cell * Pos
a position is the address of a cell
Definition List.h:132
constexpr int NIL
no node
Definition Visit.h:128
BinaryTree< T > * copy(const BinaryTree< T > *t)
a deep copy of the subtree , nil if is nil; the caller owns it