RWTPtrSlistIterator(3C++) RWTPtrSlistIterator(3C++)
Name
RWTPtrSlistIterator<T> - Rogue Wave library class
Synopsis
#include <rw/tpslist.h>
RWTPtrSlist<T> list;
RWTPtrSlistIterator<T> iterator(list);
Please Note!
If you do not have the Standard C++ Library, use the interface described
here. Otherwise, use the interface to RWTPtrSlistIterator described in
the Class Reference.
Description
Iterator for class RWTPtrSlist<T>, allowing sequential access to all the
elements of a singly-linked parameterized list. Elements are accessed in
order, from first to last. 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 will bring undefined results.
Persistence
None
Public Constructor
RWTPtrSlistIterator<T>(RWTPtrSlist<T>& c);
Constructs an iterator to be used with the list c.
Public Member Operators
RWBoolean
operator++();
Advances the iterator to the next item and returns TRUE. When the end of
the collection is reached, returns FALSE and the position of the iterator
will be undefined.
Page 1
RWTPtrSlistIterator(3C++) RWTPtrSlistIterator(3C++)
RWBoolean
operator+=(size_t n);
Advances the iterator n positions and returns TRUE. When the end of the
collection is reached, returns FALSE and the position of the iterator
will be undefined.
T*
operator()();
Advances the iterator to the next item and returns a pointer to it. When
the end of the collection is reached, returns nil and the position of the
iterator will be undefined.
Public Member Functions
RWTPtrSlist<T>*
container() const;
Returns a pointer to the collection over which this iterator is
iterating.
T*
findNext(const T* a);
Advances the iterator to the first element that is equal to the object
pointed to by a and returns a pointer to it. If no item is found,
returns nil and the position of the iterator will be undefined. Equality
is measured by the class-defined equality operator for type T.
T*
findNext(RWBoolean (*testFun)(T*, void*), void*);
Advances the iterator to the first element for which the tester function
pointed to by testFun returns TRUE and returns a pointer to it. If no
item is found, returns nil and the position of the iterator will be
undefined.
void
insertAfterPoint(T* a);
Inserts the object pointed to by a into the iterator's associated
collection in the position immediately after the iterator's current
position which remains unchanged.
Page 2
RWTPtrSlistIterator(3C++) RWTPtrSlistIterator(3C++)
T*
key() const;
Returns a pointer to the object at the iterator's current position. The
results are undefined if the iterator is no longer valid.
T*
remove();
Removes and returns the object at the iterator's current position from
the iterator's associated collection. Afterwards, the iterator will be
positioned at the element immediately before the removed element.
Returns nil if unsuccessful in which case the position of the iterator is
undefined. This function is relatively inefficient for a singly-linked
list.
T*
removeNext(const T* a);
Advances the iterator to the first element that is equal to the object
pointed to by a, then removes and returns it. Afterwards, the iterator
will be positioned at the element immediately before the removed element.
Returns nil if unsuccessful in which case the position of the iterator is
undefined. Equality is measured by the class-defined equality operator
for type T.
T*
removeNext(RWBoolean (*testFun)(T*, void*), void*);
Advances the iterator to the first element for which the tester function
pointed to by testFun returns TRUE, then removes and returns it.
Afterwards, the iterator will be positioned at the element immediately
before the removed element. Returns nil if unsuccessful in which case
the position of the iterator is undefined.
void
reset();
Resets the iterator to the state it had immediately after construction.
void
reset(RWTPtrSlist<T>& c);
Resets the iterator to iterate over the collection c.
Page 3