Template Class CursorBinaryTree

Nested Relationships

Nested Types

Class Documentation

template<class T>
class CursorBinaryTree

a binary tree on a vector of nodes linked by their places

Public Types

using Item = T

the type of the values

Public Functions

CursorBinaryTree(void) = default
explicit CursorBinaryTree(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 left(int n) const
int right(int n) const
bool isLeaf(int n) const
const T &read(int n) const
void write(int n, const T &v)
int size(void) const

the number of nodes

int setRoot(const T &v)

the root of value v of the empty tree

int insertLeft(int n, const T &v)

a new left child of n of value v, which must be missing

int insertRight(int n, const T &v)

a new right child of n of value v, which must be missing

int insertLeft(int n, const CursorBinaryTree &t, int s)

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

int insertRight(int n, const CursorBinaryTree &t, int s)

a copy of the subtree of t in s as the right subtree 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> preorder(void) const

the nodes in preorder

inline auto nodes(void) const

the nodes, in the order of their places, bidirectional

Public Static Attributes

static constexpr int NIL = -1
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)