RWTValSetIterator(3C++) RWTValSetIterator(3C++)
Name
RWTValSetIterator<T,C> - Rogue Wave library class
Synopsis
#include<rw/tvset.h>
RWTValSet<T,C> vs;
RWTValSetIterator<T,C> itr(vs);
Standard C++ Library Dependent!RWTValSetIterator requires the Standard C++ Library.
DescriptionRWTValSetIterator is supplied with Tools.h++ 7 to provide an iterator
interface for class RWTValSetIterator that is backward compatable with
the container iterators provided in Tools.h++ 6.x. The order of iteration
over an RWTValSet is dependent on the supplied comparator object
parameter C as applied to the values stored in the container. The
current item referenced by this iterator is undefined after construction
or after a call to reset(). The iterator becomes valid after being
advanced with either a preincrement or operator(). For both operator++
and operator(), iterating past the last element will return a value
equivalent to boolean false. Continued increments will return a value
equivalent to false until reset() is called.
Persistence
None
Examples
#include<rw/tvset.h>
#include<iostream.h>
#include<rw/cstring.h>
int main(){
RWTValSet<RWCString,greater<RWCString> > a;
RWTValSetIterator<RWCString,greater<RWCString> > itr(a);
a.insert("John");
a.insert("Steve");
a.insert("Mark");
//Rejected, duplicates are not allowed
a.insert("Steve");
for(;itr();)
cout << itr.key() << endl;
Page 1
RWTValSetIterator(3C++) RWTValSetIterator(3C++)
return 0;
}
Program Output
Steve
Mark
Public Constructors
John
RWTValSetIterator<T,C>(RWTValSet<T,C>&s);
Creates an iterator for the set s. The iterator begins in an undefined
state and must be advanced before the first element will be accessible
Public Member Operators
RWBoolean
operator()();
Advances self to the next element. If the iterator has advanced past the
last element in the collection, false will be returned. Otherwise, true
will be returned.
RWBoolean
operator++();
Advances self to the next element. If the iterator has been reset or
just created self will now reference the first element. If, before
iteration, self referenced the last association in the set, self will now
reference an undefined value and false will be returned. Otherwise, true
is returned. Note: no postincrement operator is provided.
Public Member Functions
RWTValSet<T,C>*
container() const;
Returns a pointer to the collection being iterated over.
T
key() const;
Returns the value referenced by self.
Page 2
RWTValSetIterator(3C++) RWTValSetIterator(3C++)
void
reset();
void
reset(RWTValSet<T,C>& s);
Resets the iterator so that after being advanced it will reference the
first element of the collection. Using reset() with no argument will
reset the iterator on the current container. Supplying a RWTValSet to
reset() will reset the iterator on that container.
Page 3