Tools.h++ Manual
104011 Tandem Computers Incorporated 21-17
21
RWBinaryTreeIterator
RWBinaryTreeIterator
|
RWIterator
Synopsis
// Smalltalk typedef:
typedef RWBinaryTreeIterator SortedCollectionIterator;
#include <rw/bintree.h>
RWBinaryTree bt;
RWBinaryTreeIterator iterate(bt);
Description Iterator for class
RWBinaryTree
. Traverses the tree from the "smallest" to
"largest" element, where "smallest" and "largest" are defined by the virtual
function
compareTo()
.
Note – This approach is generally less efficient than using the member function
RWBinaryTree::apply()
.
Like all Tools.h++ iterators, the "current item" is undefined immediately after
construction—you must define it by using
operator()
or some other (valid)
operation.
Once the iterator has advanced beyond the end of the collection it is no longer
valid—continuing to use it will bring undefined results.
Public constructor
RWBinaryTreeIterator(const RWBinaryTree&);
Constructs an iterator for a
RWBinaryTree
. Immediately after construction,
the position of the iterator is undefined until positioned.
Public member operator
virtual RWCollectable* operator()();
Redefined from class
RWIterator
. Advances iterator to the next "largest"
element and returns a pointer to it. Returns nil when the end of the collection
is reached.