WvStreams
|
The iterator type for linked lists. More...
#include <wvlinklist.h>
Public Member Functions | |
Iter (const WvList &l) | |
Binds the iterator to the specified list. More... | |
T * | ptr () const |
Returns a pointer to the current element. More... | |
WvIterStuff (T) | |
bool | get_autofree () const |
Returns the state of autofree for the current element. | |
void | set_autofree (bool autofree) |
Sets the state of autofree for the current element. | |
void | unlink (bool destroy=true) |
Unlinks the current element from the list and automatically increments the iterator to point to the next element as if next() had been called. | |
void | xunlink (bool destroy=true) |
Unlinks the current element from the list but unlike unlink() automatically returns the iterator to the previous link in the list such that next() must be called to obtain the next element. More... | |
void | rewind () |
Rewinds the iterator to make it point to an imaginary element preceeding the first element of the list. | |
WvLink * | next () |
Moves the iterator along the list to point to the next element. More... | |
WvLink * | cur () const |
Returns a pointer to the WvLink at the iterator's current location. More... | |
void * | vptr () const |
Returns a void pointer to the object at the iterator's current location. More... | |
WvLink * | find (const void *data) |
Rewinds the iterator and repositions it over the element that matches the specified value. More... | |
WvLink * | find_next (const void *data) |
Repositions the iterator over the element that matches the specified value. More... | |
Public Attributes | |
const WvListBase * | list |
WvLink * | link |
WvLink * | prev |
The iterator type for linked lists.
An iterator instance does not initially point to any valid elements in a list. Before using, it must be reset using rewind() which causes it to point to an imaginary element located before the first elements in the list. Then next() must be invoked to incrementally move the iterator along the list to first element, and then later to the second, third, and subsequent elements.
Definition at line 350 of file wvlinklist.h.
Binds the iterator to the specified list.
"l" is the list
Definition at line 357 of file wvlinklist.h.
|
inline |
Returns a pointer to the current element.
Returns: the element pointer, possibly null
Definition at line 364 of file wvlinklist.h.
|
inline |
Unlinks the current element from the list but unlike unlink() automatically returns the iterator to the previous link in the list such that next() must be called to obtain the next element.
This version allows for writing neater loop structures since an element can be unlinked in mid-traversal while still allowing the iterator to be incremented at the top of the loop as usual.
Calling xunlink() twice in a row is currently unsupported.
Definition at line 409 of file wvlinklist.h.
|
inlineinherited |
Moves the iterator along the list to point to the next element.
If the iterator had just been rewound, it now points to the first element of the list.
Returns: the current WvLink pointer, or null if there were no more elements remaining in the traversal sequence
Definition at line 103 of file wvlinklist.h.
Referenced by WvListBase::IterBase::find(), and wvtcl_encode().
|
inlineinherited |
Returns a pointer to the WvLink at the iterator's current location.
Returns: the current WvLink pointer, or null if there were no more elements remaining in the traversal sequence
Definition at line 111 of file wvlinklist.h.
|
inlineinherited |
Returns a void pointer to the object at the iterator's current location.
You should almost never need this. Use ptr() instead.
Definition at line 118 of file wvlinklist.h.
|
inherited |
Rewinds the iterator and repositions it over the element that matches the specified value.
Uses pointer equality (object identity) as the criteria for finding the matching element.
In order to locate multiple matching elements, first call find() and then use find_next().
Returns: the current WvLink pointer, or null if no such element was found
Definition at line 58 of file wvlinklist.cc.
References WvListBase::IterBase::next(), and WvListBase::IterBase::rewind().
|
inherited |
Repositions the iterator over the element that matches the specified value.
Uses pointer equality (object identity) as the criteria for finding the matching element.
Returns: the current WvLink pointer, or null if no such element was found
Definition at line 66 of file wvlinklist.cc.