1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 a sorted collection of key/value pairs optimised for searching
6 and traversing in order.
8 <!-- ##### SECTION Long_Description ##### -->
10 The #GTree structure and its associated functions provide a sorted collection
11 of key/value pairs optimised for searching and traversing in order.
14 To create a new #GTree use g_tree_new().
17 To insert a key/value pair into a #GTree use g_tree_insert().
20 To lookup the value corresponding to a given key, use g_tree_lookup() and
21 g_tree_lookup_extended().
24 To find out the number of nodes in a #GTree, use g_tree_nnodes().
25 To get the height of a #GTree, use g_tree_height().
28 To traverse a #GTree, calling a function for each node visited in the
29 traversal, use g_tree_foreach().
32 To remove a key/value pair use g_tree_remove().
35 To destroy a #GTree, use g_tree_destroy().
38 <!-- ##### SECTION See_Also ##### -->
43 <!-- ##### STRUCT GTree ##### -->
45 The #GTree struct is an opaque data structure representing a
46 <link linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>.
47 It should be accessed only by using the following functions.
51 <!-- ##### FUNCTION g_tree_new ##### -->
60 <!-- ##### FUNCTION g_tree_new_with_data ##### -->
70 <!-- ##### FUNCTION g_tree_new_full ##### -->
82 <!-- ##### FUNCTION g_tree_insert ##### -->
92 <!-- ##### FUNCTION g_tree_replace ##### -->
102 <!-- ##### FUNCTION g_tree_nnodes ##### -->
111 <!-- ##### FUNCTION g_tree_height ##### -->
120 <!-- ##### FUNCTION g_tree_lookup ##### -->
130 <!-- ##### FUNCTION g_tree_lookup_extended ##### -->
140 <!-- ##### FUNCTION g_tree_foreach ##### -->
150 <!-- ##### FUNCTION g_tree_traverse ##### -->
161 <!-- ##### USER_FUNCTION GTraverseFunc ##### -->
163 Specifies the type of function passed to g_tree_traverse().
164 It is passed the key and value of each node, together with
165 the @user_data parameter passed to g_tree_traverse().
166 If the function returns %TRUE, the traversal is stopped.
169 @key: a key of a #GTree node.
170 @value: the value corresponding to the key.
171 @data: user data passed to g_tree_traverse().
172 @Returns: %TRUE to stop the traversal.
175 <!-- ##### ENUM GTraverseType ##### -->
177 Specifies the type of traveral performed by g_tree_traverse(),
178 g_node_traverse() and g_node_find().
181 @G_IN_ORDER: vists a node's left child first, then the node itself, then its
182 right child. This is the one to use if you want the output sorted according
183 to the compare function.
184 @G_PRE_ORDER: visits a node, then its children.
185 @G_POST_ORDER: visits the node's children, then the node itself.
186 @G_LEVEL_ORDER: is not implemented for
187 <link linkend="glib-Balanced-Binary-Trees">Balanced Binary Trees</link>.
188 For <link linkend="glib-N-ary-Trees">N-ary Trees</link>, it vists the root
189 node first, then its children, then its grandchildren, and so on. Note that
190 this is less efficient than the other orders.
192 <!-- ##### FUNCTION g_tree_search ##### -->
203 <!-- ##### FUNCTION g_tree_remove ##### -->
212 <!-- ##### FUNCTION g_tree_steal ##### -->
221 <!-- ##### FUNCTION g_tree_destroy ##### -->