RWBinaryTreeIterator(3C++) RWBinaryTreeIterator(3C++)
NameRWBinaryTreeIterator - Rogue Wave library class
Synopsis
// Smalltalk typedef:
typedef RWBinaryTreeIterator SortedCollectionIterator;
#include <rw/bintree.h>
RWBinaryTree bt;
RWBinaryTreeIteratoriterate(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 that this approach is generally less
efficient than using the member function RWBinaryTree::apply(). Like all
Rogue Wave 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.
Persistence
None
Public Constructor
RWBinaryTreeIterator(const RWBinaryTree&);
Constructs an iterator for an 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.
Public Member Functions
virtual RWCollectable*
findNext(const RWCollectable* target);
Redefined from class RWIterator. Moves iterator to the next item which
Page 1
RWBinaryTreeIterator(3C++) RWBinaryTreeIterator(3C++)
compares equal to the object pointed to by target and returns it. If no
item is found, returns nil and the position of the iterator will be
undefined.
virtual void
reset();
Redefined from class RWIterator. Resets iterator to its state at
construction.
virtual RWCollectable*
key() const;
Redefined from class RWIterator. Returns the item at the current
iterator position.
Page 2