mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
GTree: add an ability to iterate over a tree and a node-based API
The basic API that this commit adds allows in-order iterating over a GTree. For this the following API were implemented or exported: 1) Returning the first or the last node in the tree, 2) Taking a pointer to a node in the tree and returning the previous or the next in-order node, 3) Allowing to do a binary search for a particular key value and returning the pointer to its node, 4) Returning the newly inserted or set node from both insert and replace functions, so this node is immediately available and does not have to be looked up, 5) Traversing the tree in-order providing a node pointer to the caller-provided traversal function. Most of the above functions were already present in the code, but they returned the value that is stored at a particular node instead of the pointer to the node itself. So most of the code for these new API calls is shared with these existing ones, just adapted to return the pointer to the node. Additionally, the so called "lower bound" and "upper bound" operations were implemented. The first one returns the first element that is greater than or equal to the searched key, while the second returns the first element that is strictly greater than the searched key. Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
This commit is contained in:
committed by
Philip Withnall
parent
260e80f1df
commit
2e7931c760
@@ -2982,21 +2982,36 @@ g_bytes_get_type
|
||||
<TITLE>Balanced Binary Trees</TITLE>
|
||||
<FILE>trees-binary</FILE>
|
||||
GTree
|
||||
GTreeNode
|
||||
g_tree_new
|
||||
g_tree_ref
|
||||
g_tree_unref
|
||||
g_tree_new_with_data
|
||||
g_tree_new_full
|
||||
g_tree_node_first
|
||||
g_tree_node_last
|
||||
g_tree_node_previous
|
||||
g_tree_node_next
|
||||
g_tree_insert_node
|
||||
g_tree_insert
|
||||
g_tree_replace_node
|
||||
g_tree_replace
|
||||
g_tree_node_key
|
||||
g_tree_node_value
|
||||
g_tree_nnodes
|
||||
g_tree_height
|
||||
g_tree_lookup_node
|
||||
g_tree_lookup
|
||||
g_tree_lookup_extended
|
||||
g_tree_foreach_node
|
||||
g_tree_foreach
|
||||
g_tree_traverse
|
||||
GTraverseFunc
|
||||
GTraverseNodeFunc
|
||||
g_tree_search_node
|
||||
g_tree_search
|
||||
g_tree_lower_bound
|
||||
g_tree_upper_bound
|
||||
g_tree_remove
|
||||
g_tree_steal
|
||||
g_tree_destroy
|
||||
|
Reference in New Issue
Block a user