SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
RWBagConstIterator Class Reference

Iterator for class RWBag, which allows sequential access to all the elements of RWBag but allows no changes. More...

#include <rw/rwbag.h>

Inheritance diagram for RWBagConstIterator:
RWConstIterator

Public Member Functions

 RWBagConstIterator (const RWBag &)
 
 RWBagConstIterator (const RWBagIterator &it)
 
virtual const RWCollectablefindNext (const RWCollectable *target)
 
virtual const RWCollectablekey () const
 
virtual const RWCollectableoperator() ()
 
virtual void reset ()
 

Detailed Description

Provides an iterator for class RWBag that allows sequential access to all the elements of RWBag and that does not change any member of RWBag. Note that because an RWBag is unordered, elements are not accessed in any particular order. If an item was inserted N times into the collection, then it is visited N consecutive times.

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, so continuing to use it has undefined results.

Synopsis
#include <rw/rwbag.h>
Iterator for class RWBag, which allows sequential access to all the elements of RWBag but allows no c...
Definition rwbag.h:366
Corresponds to the Smalltalk class Bag, representing a group of unordered elements not accessible by ...
Definition rwbag.h:65
Persistence
None

Constructor & Destructor Documentation

◆ RWBagConstIterator() [1/2]

RWBagConstIterator::RWBagConstIterator ( const RWBag & )

Constructs a const iterator for an RWBag. After construction, the position of the iterator is undefined.

◆ RWBagConstIterator() [2/2]

RWBagConstIterator::RWBagConstIterator ( const RWBagIterator & it)
inline

Constructs a const iterator from an iterator. After construction, the position of the const iterator is undefined.

Member Function Documentation

◆ findNext()

virtual const RWCollectable * RWBagConstIterator::findNext ( const RWCollectable * target)
virtual

Moves the iterator to the next item that isEqual() to the object pointed to by target, and returns it. Uses hashing to find the target. If no item is found, returns rwnil and the position of the iterator is undefined.

Implements RWConstIterator.

◆ key()

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

Returns the item at the current iterator position.

Implements RWConstIterator.

◆ operator()()

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

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

Implements RWConstIterator.

◆ reset()

virtual void RWBagConstIterator::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.