SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWBinaryTreeConstIterator Class Reference

Iterator for class RWBinaryTree that allows no changes to the values in the binary tree. More...

#include <rw/bintree.h>

Inheritance diagram for RWBinaryTreeConstIterator:
RWConstIterator

Public Member Functions

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

Detailed Description

Provides a const iterator for class RWBinaryTree. Traverses the tree from the smallest to the 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
#include <rw/bintree.h>
Iterator for class RWBinaryTree that allows no changes to the values in the binary tree.
Definition bintree.h:377
Represents a group of ordered elements, as sorted by a comparison method, and allowing duplicates.
Definition bintree.h:51
Persistence
None

Constructor & Destructor Documentation

◆ RWBinaryTreeConstIterator() [1/2]

RWBinaryTreeConstIterator::RWBinaryTreeConstIterator ( const RWBinaryTree & )

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

◆ RWBinaryTreeConstIterator() [2/2]

RWBinaryTreeConstIterator::RWBinaryTreeConstIterator ( const RWBinaryTreeIterator & it)
inline

Constructs a const iterator from an iterator. Immediately after construction, the position of the const iterator is undefined until positioned.

Member Function Documentation

◆ findNext()

virtual const RWCollectable * RWBinaryTreeConstIterator::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 RWConstIterator.

◆ key()

virtual const RWCollectable * RWBinaryTreeConstIterator::key ( ) const
virtual

Returns the item at the current iterator position.

Implements RWConstIterator.

◆ operator()()

virtual const RWCollectable * RWBinaryTreeConstIterator::operator() ( )
virtual

Advances iterator to the next largest element and returns a pointer to it. Returns rwnil when the end of the collection is reached.

Implements RWConstIterator.

◆ reset()

virtual void RWBinaryTreeConstIterator::reset ( )
virtual

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

Implements RWConstIterator.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.