RWTPtrDlistIterator(3C++) RWTPtrDlistIterator(3C++)
Name
RWTPtrDlistIterator<T> - Rogue Wave library class
Synopsis
#include <rw/tpdlist.h>
RWTPtrDlist<T> list;
Please Note!
RWTPtrDlistIterator<T> iterator(list);
If you do not have the Standard C++ Library, use the interface described
here. Otherwise, use the interface to RWTPtrDlistIterator described in
the Class Reference.
Description
Iterator for class RWTPtrDlist<T>, allowing sequential access to all the
elements of a doubly-linked parameterized list. Elements are accessed in
order, in either direction. 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
RWTPtrDlistIterator<T>(RWTPtrDlist<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
Page 1
RWTPtrDlistIterator(3C++) RWTPtrDlistIterator(3C++)
will be undefined.
RWBoolean
operator--();
Retreats the iterator to the previous item and returns TRUE. When the
beginning of the collection is reached, returns FALSE and the position of
the iterator will be undefined.
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.
RWBoolean
operator-=(size_t n);
Retreats the iterator n positions and returns TRUE. When the beginning
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
RWTPtrDlist<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.
Page 2
RWTPtrDlistIterator(3C++) RWTPtrDlistIterator(3C++)
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.
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. If the first element of the iterator's associated collection
is removed, then the position of the iterator will be undefined.
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.
Page 3
RWTPtrDlistIterator(3C++) RWTPtrDlistIterator(3C++)
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(RWTPtrDlist<T>& c);
Resets the iterator to iterate over the collection c.
Page 4