lookup
Description:
Gets the value corresponding to the given key.
Since a Tree is automatically balanced as key/value pairs are added, key lookup is O(log n) (where n is the number of key/value pairs in the tree).
Example: Lookup:
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");
// Output: ``value=val2``
string val = tree.lookup ("key2");
print ("value=%s\n", val);
return 0;
}
valac --pkg glib-2.0 GLib.Tree.lookup.vala
Parameters:
this |
a Tree |
key |
the key to look up |
Returns:
the value corresponding to the key, or null if the key was not found |