Module: Essential Tools Module Group: RWCollectable
#include <rw/bintree.h> RWBinaryTree bt; RWBinaryTreeConstIterator iterate(bt);
Provides a const 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 brings undefined results.
Constructs an iterator for an RWBinaryTree. Immediately after construction, the position of the iterator is undefined until positioned.
virtual const RWCollectable* operator()();
Redefined from class RWConstIterator. Advances iterator to the next "largest" element and returns a pointer to it. Returns nil when the end of the collection is reached.
virtual const RWCollectable* findNext(const RWCollectable* target);
Redefined from class RWConstIterator. Moves iterator to the next item which 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 is undefined.
virtual void reset();
Redefined from class RWConstIterator. Resets iterator to its state at construction.
virtual const RWCollectable* key() const;
Redefined from class RWConstIterator. Returns the item at the current iterator position.
©2004 Copyright Quovadx, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.