TaPAS  0.2
Data Structures | Typedefs | Functions
ccl-tree.h File Reference

Generic not ordered tree structure. More...

#include <ccl/ccl-protos.h>
#include <ccl/ccl-list.h>

Go to the source code of this file.

Data Structures

struct  ccl_tree_st
 Structure storing a node of a generic tree. More...
 

Typedefs

typedef struct ccl_tree_st ccl_tree
 Structure storing a node of a generic tree.
 

Functions

ccl_treeccl_tree_create (void *obj, ccl_delete_proc *del)
 Create a leaf node label with the object obj. More...
 
ccl_treeccl_tree_add_reference (ccl_tree *t)
 Increments the counter of references to the tree t. More...
 
void ccl_tree_del_reference (ccl_tree *t)
 Suppresses one reference to t. When no more reference exists the node is deleted. More...
 
int ccl_tree_get_depth (const ccl_tree *t)
 Returns the depth of the tree t. More...
 
int ccl_tree_is_leaf (const ccl_tree *t)
 Checks if the node t is a leaf. More...
 
int ccl_tree_get_nb_siblings (const ccl_tree *t)
 Returns the number of siblings of t. More...
 
int ccl_tree_get_nb_childs (const ccl_tree *t)
 Returns the number of childs of t. More...
 
ccl_treeccl_tree_get_child (ccl_tree *t, int index)
 Returns the index th child of t. More...
 
void ccl_tree_add_child (ccl_tree *t, ccl_tree *child)
 Add a new child to the tree t The child is added at the end of the liust of sons of t. A new reference is added to child. More...
 
void ccl_tree_set_label (ccl_tree *t, void *obj, ccl_delete_proc *del)
 Changes the label of t with the object obj. More...
 

Detailed Description

Generic not ordered tree structure.

This module implements a generic tree whose nodes are labelled with objects pointed by void pointers.

Definition in file ccl-tree.h.

Function Documentation

void ccl_tree_add_child ( ccl_tree t,
ccl_tree child 
)

Add a new child to the tree t The child is added at the end of the liust of sons of t. A new reference is added to child.

Parameters
tthe tree
childthe new child
Precondition
t != NULL
child != NULL
Returns
child of t at the position index
ccl_tree* ccl_tree_add_reference ( ccl_tree t)

Increments the counter of references to the tree t.

Parameters
tthe tree
Precondition
t != NULL
Returns
t
ccl_tree* ccl_tree_create ( void *  obj,
ccl_delete_proc del 
)

Create a leaf node label with the object obj.

Parameters
objthe object that labels the node
delthe deletion procedure applyed to obj when the node is deleted or the label replaced.
Returns
a new leaf node
void ccl_tree_del_reference ( ccl_tree t)

Suppresses one reference to t. When no more reference exists the node is deleted.

Parameters
tthe tree
Precondition
t != NULL
t->refcount > 0
ccl_tree* ccl_tree_get_child ( ccl_tree t,
int  index 
)

Returns the index th child of t.

Parameters
tthe tree
indexthe index of the child
Precondition
0 <= index && index < ccl_tree_get_nb_childs (t)
Returns
child of t at the position index
int ccl_tree_get_depth ( const ccl_tree t)

Returns the depth of the tree t.

The depth of t is the number of nodes in the maximal path from the root t to one of its leaves.

Parameters
tthe tree
Precondition
t != NULL
Returns
the depth of the tree t
int ccl_tree_get_nb_childs ( const ccl_tree t)

Returns the number of childs of t.

Parameters
tthe tree
Precondition
t != NULL
Returns
the number of childs of t; 0 if t is a leaf.
int ccl_tree_get_nb_siblings ( const ccl_tree t)

Returns the number of siblings of t.

The function counts only siblings accessible from t not those placed before t in the linked list of sons.

Parameters
tthe tree
Precondition
t != NULL
Returns
the number of siblings of t.
int ccl_tree_is_leaf ( const ccl_tree t)

Checks if the node t is a leaf.

Parameters
tthe tree
Precondition
t != NULL
Returns
a non-null value if t is not a leaf.
void ccl_tree_set_label ( ccl_tree t,
void *  obj,
ccl_delete_proc del 
)

Changes the label of t with the object obj.

Parameters
tthe tree
objthe new object
delthe deletion procedure applied to obj
Precondition
t != NULL