replace


Description:

public void replace (owned K key, owned V value)

Inserts a new key and value into a Tree as replace_node does, only this function does not return the inserted or set node.

Example: Inserts/replace a new key and value:

public static int main (string[] args) {
Tree<string, string> tree = new Tree<string, string>.full ((a, b) => { return strcmp (a, b); }, free, free);
tree.insert ("key1", "val1");
tree.insert ("key2", "val3");

tree.replace ("key2", "val2");
tree.replace ("key3", "val3");

// Output:
// ``key=key1, value=val1``
// ``key=key2, value=val2``
// ``key=key3, value=val3``
tree.@foreach ((key, val) => {
print ("key=%s, value=%s\n", (string) key, (string) val);
return false;
});

return 0;
}

valac --pkg glib-2.0 GLib.Tree.replace.vala

Parameters:

this

a Tree

key

the key to insert

value

the value corresponding to the key