Method

GLibTreereplace_node

since: 2.68

Declaration

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

Description

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.

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.

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 function.
value

Type: gpointer

The value corresponding to the key.

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

Return value

Type: GTreeNode

The inserted (or set) node.

The data is owned by the instance.