Method

GLibTreeinsert_node

since: 2.68

Declaration [src]

GTreeNode*
g_tree_insert_node (
  GTree* tree,
  gpointer key,
  gpointer value
)

Description [src]

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

Available since: 2.68

Parameters

key

Type: gpointer

The key to insert.

The argument can be NULL.
The data is owned by the caller of the method.
value

Type: gpointer

The value corresponding to the key.

The argument can be NULL.
The data is owned by the caller of the method.

Return value

Type: GTreeNode

The inserted (or set) node or NULL if insertion would overflow the tree node counter.

The returned data is owned by the instance.
The return value can be NULL.