Template Class CursorTree

Nested Relationships

Nested Types

Class Documentation

template<class T>
class CursorTree

an ordered tree on a vector of nodes linked by their places

Public Types

using Item = T

the type of the values

Public Functions

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

a tree of one node of value v

bool empty(void) const
int root(void) const
int parent(int n) const
int leftmostChild(int n) const
int rightSibling(int n) const
bool isLeaf(int n) const
bool isLastSibling(int n) const

whether n is the last of its siblings

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

a new first child of n of value v

int insertSibling(int n, const T &v)

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

int insertChildTree(int n, const CursorTree &t, int s)

a copy of the subtree of t in s as the first child of n; t may be this tree, copied as it was before the call

int insertSiblingTree(int n, const CursorTree &t, int s)

a copy of the subtree of t in s as the next sibling of n; t may be this tree, copied as it was before the call

void remove(int n)

removes the subtree of n, detached from its parent

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
inline auto nodes(void) const

the nodes, in the order of their places, bidirectional

inline auto children(int n) const

the children of n, from the leftmost, forward

Pre:

n is a node

Public Static Attributes

static constexpr int NIL = -1
struct Siblings

the walk of the children of a node

Public Static Functions

static inline int next(const CursorTree *o, int n, int)

Public Static Attributes

static constexpr int none = NIL
struct Used

the places in use, for SlotIterator

Public Static Functions

static inline std::size_t size(const auto &o)
static inline bool occupied(const auto &o, std::size_t i)
static inline int read(const auto&, std::size_t i)