height


Description:

public int height ()

Gets the height of a Tree.

If the Tree contains no nodes, the height is 0. If the Tree contains only one root node the height is 1. If the root node has children the height is 2, etc.

Example: Get the height of the tree:

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 ("key4", "val4");

// Output: ``Tree, height: 3``
int height = tree.height ();
print ("Tree, height: %d\n", height);

return 0;
}

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

Parameters:

this

a Tree

Returns:

the height of this