Struct bstree

Struct Documentation

struct bstree

Binary Search Tree using approach from Introduction to Algorithms.

Public Members

int (*cmpkey)(const void *const a, const void *const b)

For comparing the keys from two different elements. Cannot be NULL.

void (*printe)(const void *const e)

For printing an element. Can be NULL.

struct bstree_space_mgmt space

Management of all node and element space for the tree.

size_t current

Number of nodes/elements currently in the tree.

size_t depth

Current depth as a traversal progresses.

uint32_t flags

Configuration flags. Valid flags are:

All other flags are ignored.

int max_elts

Max # of elements for tree. -1 indicates no limit.

size_t elt_size

Size of each element in bytes.

struct bstree_node *root

Root of the tree (sentinel). root->left should always point to the node which is the root of the tree. Use this so that there are fewer special cases/less checking for NULL pointers.

struct bstree_node *nil

Sentinel. Points to a node which should always be black (for red-black trees) but has aribtrary children and parent. Use this so that there are no fewer special cases in the code/less checking for NULL pointers.