rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWBinaryTreeIterator Class Reference
[RWCollectable-derived]

Iterator for class RWBinaryTree. More...

#include <rw/bintree.h>

Inheritance diagram for RWBinaryTreeIterator:
RWIterator

List of all members.

Public Member Functions

 RWBinaryTreeIterator (const RWBinaryTree &)
virtual ~RWBinaryTreeIterator ()
virtual RWCollectablefindNext (const RWCollectable *target)
virtual RWCollectablekey () const
virtual RWCollectableoperator() ()
virtual void reset ()

Detailed Description

Iterator for class RWBinaryTree. Traverses the tree from the smallest to largest element, where "smallest" and "largest" are defined by the virtual function RWBinaryTree::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 leads to undefined results.

Synopsis

 // Smalltalk typedef:
 typedef RWBinaryTreeIterator SortedCollectionIterator;
 #include <rw/bintree.h>
 RWBinaryTree bt;
 RWBinaryTreeIterator iterate(bt);

Persistence

None


Constructor & Destructor Documentation

RWBinaryTreeIterator::RWBinaryTreeIterator ( const RWBinaryTree  ) 

Constructs an iterator for an RWBinaryTree. Immediately after construction, the position of the iterator is undefined until positioned.

virtual RWBinaryTreeIterator::~RWBinaryTreeIterator (  )  [virtual]

Empty destructor.


Member Function Documentation

virtual RWCollectable* RWBinaryTreeIterator::findNext ( const RWCollectable target  )  [virtual]

Moves iterator to the next item that compares equal to the object pointed to by target and returns it. If no item is found, returns rwnil and the position of the iterator is undefined.

Implements RWIterator.

virtual RWCollectable* RWBinaryTreeIterator::key (  )  const [virtual]

Returns the item at the current iterator position.

Implements RWIterator.

virtual RWCollectable* RWBinaryTreeIterator::operator() (  )  [virtual]

Advances the iterator and returns the next item, or rwnil if the end of the collection has been reached.

Implements RWIterator.

virtual void RWBinaryTreeIterator::reset (  )  [virtual]

Resets the iterator to the state it had immediately after construction.

Implements RWIterator.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, 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.