Next: rbtree_node_size, Previous: rbtree_min_node, Up: Public Routines
Create the root of a red-black tree.
#include <rbtree/rbtree.h>RBTree rbtree_new(int (*cmp)(const void *,const void *));
int (*cmp)(const void *,const void *)
- a node comparison routine used to sort the nodes
This routine creates the data structures necessary to implement the root of a red-black tree. It requires a node comparison function which will be used to sort the nodes.
The comparison routine is usually only used for sorting, not searching, but may be if a search or destroy routine is called without a specific comparison routine. It should return `-1', `0', or `1' depending upon whether the first node is respectively less than, equal to, or greater than the second node.
It returns a handle to the new tree if successful, NULL
if not.