Template Class ChildListTree

Nested Relationships

Nested Types

Class Documentation

template<class T>
class ChildListTree

an ordered tree whose nodes keep the list of their children

Public Types

using Item = T

the type of the values

Public Functions

ChildListTree(void) = default
explicit ChildListTree(const T &v)

a tree of one node of value v

bool empty(void) const
int root(void) const
int parent(int n) const
Pre:

n is a node

int leftmostChild(int n) const
Pre:

n is a node

int rightSibling(int n) const
Pre:

n is a node

bool isLeaf(int n) const
Pre:

n is a node

bool isLastSibling(int n) const

whether n is the last of its siblings

Pre:

n is a node

const List<int> &children(int n) const

the list of the children of n, in their order

Pre:

n is a node

const T &read(int n) const
Pre:

n is a node

void write(int n, const T &v)
Pre:

n is a node

int size(void) const
int insertChild(int n, const T &v)

a new first child of n of value v

Pre:

n is a node

int insertSibling(int n, const T &v)

a new next sibling of n, not the root, of value v

Pre:

n is a node other than the root

void remove(int n)

removes the subtree of n, detached from its parent

Pre:

n is a node

std::vector<int> previsit(void) const

the nodes in previsit, postvisit, and invisit with index i

std::vector<int> postvisit(void) const
std::vector<int> invisit(int i) const

Public Static Attributes

static constexpr int NIL = -1