Member Functions | |
container() findNext() insertAfterPoint() key() operator()() operator++() operator+=() remove() removeNext() reset() |
#include <rw/tvslist.h> RWTValSlist<T> list; RWTValSlistIterator<T> iterator(list);
If you do not have the Standard C++ Library, use the interface described here. Otherwise, use the interface to RWTValSlistIterator described in the Class Reference.
Iterator for class RWTValSlist<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.
None
#include<rw/tvslist.h> #include<iostream.h> #include<rw/cstring.h> int main(){ RWTValSlist<RWCString> a; RWTValSlistIterator<RWCString> itr(a); a.insert("John"); a.insert("Steve"); a.insert("Mark"); a.insert("Steve"); for(;itr();) cout << itr.key() << endl; return 0; } Program Output John Steve Mark Steve
RWTValSlistIterator<T>(RWTValSlist<T>& c);
Constructs an iterator to be used with the list c.
RWBoolean operator++();
Advances the iterator one position. Returns TRUE if the new position is valid, FALSE otherwise.
RWBoolean operator+=(size_t n);
Advances the iterator n positions. Returns TRUE if the new position is valid, FALSE otherwise.
RWBoolean operator()();
Advances the iterator one position. Returns TRUE if the new position is valid, FALSE otherwise.
RWTValSlist<T>* container() const;
Returns a pointer to the collection over which this iterator is iterating.
RWBoolean findNext(const T& a);
Advances the iterator to the first element that is equal to a and returns TRUE, or FALSE if there is no such element. Equality is measured by the class-defined equality operator for type T.
RWBoolean findNext(RWBoolean (*testFun)(const T&, void*),void*);
Advances the iterator to the first element for which the tester function pointed to by testFun returns TRUE and then returns TRUE, or FALSE if there is no such element.
void insertAfterPoint(const T& a);
Inserts the value a into the iterator's associated collection in the position immediately after the iterator's current position.
T key() const;
Returns the value at the iterator's current position. The results are undefined if the iterator is no longer valid.
RWBoolean remove();
Removes the value from the iterator's associated collection at the current position of the iterator. Returns TRUE if successful, FALSE otherwise. Afterwards, if successful, the iterator will be positioned at the element immediately before the removed element. This function is relatively inefficient for a singly-linked list.
RWBoolean removeNext(const T& a);
Advances the iterator to the first element that is equal to a and removes it. Returns TRUE if successful, FALSE otherwise. Equality is measured by the class-defined equality operator for type T. Afterwards, if successful, the iterator will be positioned at the element immediately before the removed element.
RWBoolean removeNext(RWBoolean (*testFun)(const T&, void*),void*);
Advances the iterator to the first element for which the tester function pointed to by testFun returns TRUE and removes it. Returns TRUE if successful, FALSE otherwise. Afterwards, if successful, the iterator will be positioned at the element immediately before the removed element.
void reset();
Resets the iterator to the state it had immediately after construction.
void reset(RWTValSlist<T>& c);
Resets the iterator to iterate over the collection c.