<!-- ##### SECTION Title ##### --> Balanced Binary Trees <!-- ##### SECTION Short_Description ##### --> a sorted collection of key/value pairs optimized for searching and traversing in order. <!-- ##### SECTION Long_Description ##### --> <para> The #GTree structure and its associated functions provide a sorted collection of key/value pairs optimized for searching and traversing in order. </para> <para> To create a new #GTree use g_tree_new(). </para> <para> To insert a key/value pair into a #GTree use g_tree_insert(). </para> <para> To lookup the value corresponding to a given key, use g_tree_lookup() and g_tree_lookup_extended(). </para> <para> To find out the number of nodes in a #GTree, use g_tree_nnodes(). To get the height of a #GTree, use g_tree_height(). </para> <para> To traverse a #GTree, calling a function for each node visited in the traversal, use g_tree_foreach(). </para> <para> To remove a key/value pair use g_tree_remove(). </para> <para> To destroy a #GTree, use g_tree_destroy(). </para> <!-- ##### SECTION See_Also ##### --> <para> </para> <!-- ##### STRUCT GTree ##### --> <para> The <structname>GTree</structname> struct is an opaque data structure representing a <link linkend="glib-Balanced-Binary-Trees">Balanced Binary Tree</link>. It should be accessed only by using the following functions. </para> <!-- ##### FUNCTION g_tree_new ##### --> <para> </para> @key_compare_func: @Returns: <!-- ##### FUNCTION g_tree_new_with_data ##### --> <para> </para> @key_compare_func: @key_compare_data: @Returns: <!-- ##### FUNCTION g_tree_new_full ##### --> <para> </para> @key_compare_func: @key_compare_data: @key_destroy_func: @value_destroy_func: @Returns: <!-- ##### FUNCTION g_tree_insert ##### --> <para> </para> @tree: @key: @value: <!-- ##### FUNCTION g_tree_replace ##### --> <para> </para> @tree: @key: @value: <!-- ##### FUNCTION g_tree_nnodes ##### --> <para> </para> @tree: @Returns: <!-- ##### FUNCTION g_tree_height ##### --> <para> </para> @tree: @Returns: <!-- ##### FUNCTION g_tree_lookup ##### --> <para> </para> @tree: @key: @Returns: <!-- ##### FUNCTION g_tree_lookup_extended ##### --> @tree: @lookup_key: @orig_key: @value: @Returns: <!-- ##### FUNCTION g_tree_foreach ##### --> <para> </para> @tree: @func: @user_data: <!-- ##### FUNCTION g_tree_traverse ##### --> <para> </para> @tree: @traverse_func: @traverse_type: @user_data: <!-- ##### USER_FUNCTION GTraverseFunc ##### --> <para> Specifies the type of function passed to g_tree_traverse(). It is passed the key and value of each node, together with the @user_data parameter passed to g_tree_traverse(). If the function returns %TRUE, the traversal is stopped. </para> @key: a key of a #GTree node. @value: the value corresponding to the key. @data: user data passed to g_tree_traverse(). @Returns: %TRUE to stop the traversal. <!-- ##### ENUM GTraverseType ##### --> <para> Specifies the type of traveral performed by g_tree_traverse(), g_node_traverse() and g_node_find(). </para> @G_IN_ORDER: vists a node's left child first, then the node itself, then its right child. This is the one to use if you want the output sorted according to the compare function. @G_PRE_ORDER: visits a node, then its children. @G_POST_ORDER: visits the node's children, then the node itself. @G_LEVEL_ORDER: is not implemented for <link linkend="glib-Balanced-Binary-Trees">Balanced Binary Trees</link>. For <link linkend="glib-N-ary-Trees">N-ary Trees</link>, it vists the root node first, then its children, then its grandchildren, and so on. Note that this is less efficient than the other orders. <!-- ##### FUNCTION g_tree_search ##### --> <para> </para> @tree: @search_func: @user_data: @Returns: <!-- ##### FUNCTION g_tree_remove ##### --> <para> </para> @tree: @key: <!-- ##### FUNCTION g_tree_steal ##### --> <para> </para> @tree: @key: <!-- ##### FUNCTION g_tree_destroy ##### --> <para> </para> @tree: