tree_create function <BLOC/tree.h>

The tree_create function creates a tree object. A tree can have an associated type of object, or it can be for any object type. This can be specified when creating the tree. Since trees are ordered, the objects will usually need to be of the same type. In theory, though, a tree could sort objects that have the same header.

Syntax

Tree *
tree_create(
	struct ObjectType *type,
	int (*compare)(void *, void *)
);

Parameters

type

A pointer to an ObjectType structure describing the type of object allowed in the tree. If NULL, the tree will accept objects of any type.

compare

A pointer to a function that will determine the order of two objects. The function should take two generic pointer parameters, which will represent the two objects to be ordered. It should return an integer value indicating the result of the comparison:

Return value

A reference pointer to the newly created Tree object.