[464:14] static extends: object
Alternate constructors for GTree. Usage:
GTreeCtors.<name>(...). The primary constructor lives
directly on GTree.
newFull (object key_compare_func, object key_destroy_func)
Creates a new #GTree like g_tree_new() and allows to specify functions to free the memory allocated for the key and value that get called when removing the entry from the #GTree.
key_compare_func is qsort()-style comparison function.key_compare_data is data to pass to comparison function.key_destroy_func is a function to free the memory allocated for the key used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.value_destroy_func is a function to free the memory allocated for the value used when removing the entry from the #GTree or %NULL if you don't want to supply such a function.A new GTree.[15:7] extends: object
The GTree struct is an opaque data structure representing a balanced binary tree. It should be accessed only by using the following functions.
GTree (key_compare_func = null, key_compare_data = null)
Creates a new #GTree.
key_compare_func is the function used to order the nodes in the #GTree. It should return values similar to the standard strcmp() function - 0 if the two arguments are equal, a negative value if the first argument comes before the second, or a positive value if the first argument comes after the second..key_compare_data is data to pass to comparison function.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.destroy ()
Removes all keys and values from the #GTree and decreases its reference count by one. If keys and/or values are dynamically allocated, you should either free them first or create the #GTree using g_tree_new_full(). In the latter case the destroy functions you supplied will be called on all keys and values before destroying the #GTree.
None.foreach (user_data)
Calls the given function for each of the key/value pairs in the #GTree. The function is passed the key and value of each pair, and the given
parameter. The tree is traversed in sorted order. The tree may not be modified while iterating over it (you can't add/remove items). To remove all items matching a predicate, you need to add each item to a list in your #GTraverseFunc as you walk over the tree, then walk the list and remove each item.func is the function to call for each node visited. If this function returns %TRUE, the traversal is stopped..user_data is user data to pass to the function.None.foreach_node (user_data)
Calls the given function for each of the nodes in the #GTree. The function is passed the pointer to the particular node, and the given
parameter. The tree traversal happens in-order. The tree may not be modified while iterating over it (you can't add/remove items). To remove all items matching a predicate, you need to add each item to a list in your #GTraverseFunc as you walk over the tree, then walk the list and remove each item.func is the function to call for each node visited. If this function returns %TRUE, the traversal is stopped..user_data is user data to pass to the function.None.height ()
Gets the height of a #GTree. If the #GTree contains no nodes, the height is 0. If the #GTree contains only one root node the height is 1. If the root node has children the height is 2, etc.
the height of @tree.insert (key, value)
Inserts a key/value pair into a #GTree. Inserts a new key and value into a #GTree as g_tree_insert_node() does, only this function does not return the inserted or set node.
key is the key to insert.value is the value corresponding to the key.None.insert_node (key, value)
Inserts a key/value pair into a #GTree. If the given key already exists in the #GTree its corresponding value is set to the new value. If you supplied a @value_destroy_func when creating the #GTree, the old value is freed using that function. If you supplied a @key_destroy_func when creating the #GTree, the passed key is freed using that function. The tree is automatically 'balanced' as new key/value pairs are added, so that the distance from the root to every leaf is as small as possible. The cost of maintaining a balanced tree while inserting new key/value result in a O(n log(n)) operation where most of the other operations are O(log(n)).
key is the key to insert.value is the value corresponding to the key.the inserted (or set) node or %NULL if insertion would overflow the tree node counter..lookup (key)
Gets the value corresponding to the given key. Since a #GTree is automatically balanced as key/value pairs are added, key lookup is O(log n) (where n is the number of key/value pairs in the tree).
key is the key to look up.the value corresponding to the key, or %NULL if the key was not found.lookup_extended (lookup_key)
Looks up a key in the #GTree, returning the original key and the associated value. This is useful if you need to free the memory allocated for the original key, for example before calling g_tree_remove().
lookup_key is the key to look up.orig_key is returns the original key.value is returns the value associated with the key.%TRUE if the key was found in the #GTree.lookup_node (key)
Gets the tree node corresponding to the given key. Since a #GTree is automatically balanced as key/value pairs are added, key lookup is O(log n) (where n is the number of key/value pairs in the tree).
key is the key to look up.the tree node corresponding to the key, or %NULL if the key was not found.lower_bound (key)
Gets the lower bound node corresponding to the given key, or %NULL if the tree is empty or all the nodes in the tree have keys that are strictly lower than the searched key. The lower bound is the first node that has its key greater than or equal to the searched key.
key is the key to calculate the lower bound for.the tree node corresponding to the lower bound, or %NULL if the tree is empty or has only keys strictly lower than the searched key..nnodes ()
Gets the number of nodes in a #GTree.
the number of nodes in @tree The node counter value type is really a #guint, but it is returned as a #gint due to backward compatibility issues (can be cast back to #guint to support its full range of values)..node_first ()
Returns the first in-order node of the tree, or %NULL for an empty tree.
the first node in the tree.node_last ()
Returns the last in-order node of the tree, or %NULL for an empty tree.
the last node in the tree.ref ()
Increments the reference count of @tree by one. It is safe to call this function from any thread.
the passed in #GTree.remove (key)
Removes a key/value pair from a #GTree. If the #GTree was created using g_tree_new_full(), the key and value are freed using the supplied destroy functions, otherwise you have to make sure that any dynamically allocated values are freed yourself. If the key does not exist in the #GTree, the function does nothing. The cost of maintaining a balanced tree while removing a key/value result in a O(n log(n)) operation where most of the other operations are O(log(n)).
key is the key to remove.%TRUE if the key was found (prior to 2.8, this function returned nothing).remove_all ()
Removes all nodes from a #GTree and destroys their keys and values, then resets the #GTreeās root to %NULL.
None.replace (key, value)
Inserts a new key and value into a #GTree as g_tree_replace_node() does, only this function does not return the inserted or set node.
key is the key to insert.value is the value corresponding to the key.None.replace_node (key, value)
Inserts a new key and value into a #GTree similar to g_tree_insert_node(). The difference is that if the key already exists in the #GTree, it gets replaced by the new key. If you supplied a
when creating the #GTree, the old value is freed using that function. If you supplied a @key_destroy_func when creating the #GTree, the old key is freed using that function. The tree is automatically 'balanced' as new key/value pairs are added, so that the distance from the root to every leaf is as small as possible.key is the key to insert.value is the value corresponding to the key.the inserted (or set) node or %NULL if insertion would overflow the tree node counter..search (user_data)
Searches a #GTree using @search_func. The @search_func is called with a pointer to the key of a key/value pair in the tree, and the passed in
If @search_func returns 0 for a key/value pair, then the corresponding value is returned as the result of g_tree_search(). Ifreturns -1, searching will proceed among the key/value pairs that have a smaller key; if @search_func returns 1, searching will proceed among the key/value pairs that have a larger key.search_func is a function used to search the #GTree.user_data is the data passed as the second argument to @search_func.the value corresponding to the found key, or %NULL if the key was not found.search_node (user_data)
Searches a #GTree using @search_func. The @search_func is called with a pointer to the key of a key/value pair in the tree, and the passed in
If @search_func returns 0 for a key/value pair, then the corresponding node is returned as the result of g_tree_search(). Ifreturns -1, searching will proceed among the key/value pairs that have a smaller key; if @search_func returns 1, searching will proceed among the key/value pairs that have a larger key.search_func is a function used to search the #GTree.user_data is the data passed as the second argument to @search_func.the node corresponding to the found key, or %NULL if the key was not found.steal (key)
Removes a key and its associated value from a #GTree without calling the key and value destroy functions. If the key does not exist in the #GTree, the function does nothing.
key is the key to remove.%TRUE if the key was found (prior to 2.8, this function returned nothing).traverse (object traverse_func, user_data)
Calls the given function for each node in the #GTree.
traverse_func is the function to call for each node visited. If this function returns %TRUE, the traversal is stopped..traverse_type is the order in which nodes are visited, one of %G_IN_ORDER, %G_PRE_ORDER and %G_POST_ORDER.user_data is user data to pass to the function.None.unref ()
Decrements the reference count of @tree by one. If the reference count drops to 0, all keys and values will be destroyed (if destroy functions were specified) and all memory allocated by @tree will be released. It is safe to call this function from any thread.
None.upper_bound (key)
Gets the upper bound node corresponding to the given key, or %NULL if the tree is empty or all the nodes in the tree have keys that are lower than or equal to the searched key. The upper bound is the first node that has its key strictly greater than the searched key.
key is the key to calculate the upper bound for.the tree node corresponding to the upper bound, or %NULL if the tree is empty or has only keys lower than or equal to the searched key..