BBTree

The GTree struct is an opaque data structure representing a [balanced binary tree][glib-Balanced-Binary-Trees]. It should be accessed only by using the following functions.

Constructors

this
this(GTree* gTree, bool ownedRef)

Sets our main struct and passes it to the parent class.

this
this(GCompareFunc keyCompareFunc)

Creates a new #GTree.

this
this(GCompareDataFunc keyCompareFunc, void* keyCompareData, GDestroyNotify keyDestroyFunc, GDestroyNotify valueDestroyFunc)

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.

this
this(GCompareDataFunc keyCompareFunc, void* keyCompareData)

Creates a new #GTree with a comparison function that accepts user data. See g_tree_new() for more details.

Destructor

~this
~this()
Undocumented in source.

Members

Aliases

doref
alias doref = ref_
Undocumented in source.
foreac
alias foreac = foreach_
Undocumented in source.

Functions

destroy
void 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.

foreachNode
void foreachNode(GTraverseNodeFunc func, void* userData)

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 @data parameter. The tree traversal happens in-order.

foreach_
void foreach_(GTraverseFunc func, void* userData)

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 @data parameter. The tree is traversed in sorted order.

getBBTreeStruct
GTree* getBBTreeStruct(bool transferOwnership)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

height
int height()

Gets the height of a #GTree.

insert
void insert(void* key, void* value)

Inserts a key/value pair into a #GTree.

insertNode
TreeNode insertNode(void* key, void* value)

Inserts a key/value pair into a #GTree.

lookup
void* lookup(void* 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).

lookupExtended
bool lookupExtended(void* lookupKey, void* origKey, void* value)

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().

lookupNode
TreeNode lookupNode(void* 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).

lowerBound
TreeNode lowerBound(void* 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.

nnodes
int nnodes()

Gets the number of nodes in a #GTree.

nodeFirst
TreeNode nodeFirst()

Returns the first in-order node of the tree, or %NULL for an empty tree.

nodeLast
TreeNode nodeLast()

Returns the last in-order node of the tree, or %NULL for an empty tree.

ref_
BBTree ref_()

Increments the reference count of @tree by one.

remove
bool remove(void* key)

Removes a key/value pair from a #GTree.

replace
void replace(void* key, void* 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.

replaceNode
TreeNode replaceNode(void* key, void* 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 @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 old key is freed using that function.

search
void* search(GCompareFunc searchFunc, void* userData)

Searches a #GTree using @search_func.

searchNode
TreeNode searchNode(GCompareFunc searchFunc, void* userData)

Searches a #GTree using @search_func.

steal
bool steal(void* key)

Removes a key and its associated value from a #GTree without calling the key and value destroy functions.

traverse
void traverse(GTraverseFunc traverseFunc, GTraverseType traverseType, void* userData)

Calls the given function for each node in the #GTree.

unref
void 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.

upperBound
TreeNode upperBound(void* 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.

Variables

gTree
GTree* gTree;

the main Gtk struct

ownedRef
bool ownedRef;
Undocumented in source.

Meta