insert
Description:
Inserts a key/value pair into a Tree.
Inserts a new key and value into a Tree as insert_node does, only this function does not return the inserted or set node.
Example: Inserts 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", "val2");
tree.insert ("key3", "val3");
tree.insert ("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.insert.vala
Parameters:
this |
a Tree |
key |
the key to insert |
value |
the value corresponding to the key |