insert_node


Description:

[ Version ( since = "2.68" ) ]
public unowned TreeNode<K,V> insert_node (owned K key, owned V value)

Inserts a key/value pair into a Tree.

If the given key already exists in the Tree its corresponding value is set to the new value. If you supplied a value_destroy_func when creating the Tree, the old value is freed using that function. If you supplied a key_destroy_func when creating the Tree, 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)).

Parameters:

this

a Tree

key

the key to insert

value

the value corresponding to the key

Returns:

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