TaPAS  0.2
ccl-tree.h
Go to the documentation of this file.
1 /*
2  * ccl-tree.h -- Generic not ordered tree structure.
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Universit√© Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
24 #ifndef __CCL_TREE_H__
25 # define __CCL_TREE_H__
26 
27 # include <ccl/ccl-protos.h>
28 # include <ccl/ccl-list.h>
29 
30 BEGIN_C_DECLS
31 
35 typedef struct ccl_tree_st ccl_tree;
36 
41 {
42  int refcount;
46  void *object;
47 
52 
57 
62  ccl_tree *parent;
63 };
64 
72 extern ccl_tree *
73 ccl_tree_create (void *obj, ccl_delete_proc *del);
74 
81 extern ccl_tree *
83 
91 extern void
93 
104 extern int
105 ccl_tree_get_depth (const ccl_tree *t);
106 
113 extern int
114 ccl_tree_is_leaf (const ccl_tree *t);
115 
126 extern int
128 
135 extern int
137 
145 extern ccl_tree *
146 ccl_tree_get_child (ccl_tree *t, int index);
147 
158 extern void
160 
168 extern void
169 ccl_tree_set_label (ccl_tree *t, void *obj, ccl_delete_proc *del);
170 
171 extern ccl_list *
172 ccl_tree_get_path (ccl_tree *from, ccl_tree *to);
173 
174 extern ccl_tree *
175 ccl_tree_least_common_ancestor (ccl_tree *root, ccl_tree *v1, ccl_tree *v2);
176 
177 END_C_DECLS
178 
179 #endif /* ! __CCL_TREE_H__ */
int ccl_tree_get_nb_childs(const ccl_tree *t)
Returns the number of childs of t.
Frequently used prototypes of generic functions.
Generic simple linked list.
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...
Structure storing a node of a generic tree.
Definition: ccl-tree.h:40
ccl_tree * childs
A pointer to the first child of the node.
Definition: ccl-tree.h:61
void ccl_tree_del_reference(ccl_tree *t)
Suppresses one reference to t. When no more reference exists the node is deleted. ...
ccl_tree * ccl_tree_get_child(ccl_tree *t, int index)
Returns the index th child of t.
ccl_tree * next
A pointer to the first sibling of the node.
Definition: ccl-tree.h:56
int ccl_tree_is_leaf(const ccl_tree *t)
Checks if the node t is a leaf.
ccl_delete_proc * del
The procedure call to free resources allocated to the object.
Definition: ccl-tree.h:51
ccl_tree * ccl_tree_create(void *obj, ccl_delete_proc *del)
Create a leaf node label with the object obj.
struct ccl_list_st ccl_list
Type of a generic list.
Definition: ccl-list.h:33
void * object
The object labelling the node.
Definition: ccl-tree.h:46
void ccl_delete_proc(void *ptr)
Prototype of procedures used to release the resources allocated to the object pointed by ptr...
Definition: ccl-protos.h:44
int ccl_tree_get_nb_siblings(const ccl_tree *t)
Returns the number of siblings of t.
int ccl_tree_get_depth(const ccl_tree *t)
Returns the depth of the tree t.
void ccl_tree_set_label(ccl_tree *t, void *obj, ccl_delete_proc *del)
Changes the label of t with the object obj.
ccl_tree * ccl_tree_add_reference(ccl_tree *t)
Increments the counter of references to the tree t.