Tree Container Library: Ordered Iterators

The Tree Container Library

A C++ generic tree container library which, not only works much like the STL, but is also compatible with the STL algorithms. The Tree Container Library is used worldwide in thousands of industries and organizations. It is completely free to use, and is licensed under the zlib/libpng license.

In the TCL, the ordered iterators (ordered_iterator and const_ordered_iterator are an alternate iterator available only to the unique_tree, and offer an alternate traversal order to the standard child iterators . In a unique_tree, all nodes are guaranteed to be unique, and the second template parameter, the node_compare_type comparison operation is used to determine the difference in the nodes , and order of the child iterators. It might be useful however, to have the children within a given parent be ordered in a different manner than is given by the node_compare_type. Thus, third template parameter, the node_order_compare_type let's you define another comparison operation which will be used to define an alternate transversal order. The ordered iterators are used for this alternate transversal order. The ordered iterators are bi-directional iterators.

The main difference between the ordered iterators and the child iterators is that the child iterators use the tree's second template parameter, node_compare_type for the comparison operation, while the ordered_iterators use the tree's third template parameter, node_order_compare_type for the comparison operation.

The tree's third template parameter, node_order_compare_type, if unspecified, defaults to the tree's second template parameter, node_compare_type. You need only supply the third template parameter when you will need to be able to traverse child nodes in an order which differs from that given with the node_compare_type.