Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

WvList< T >::Iter Class Reference

#include <wvlinklist.h>

Inherits WvListBase::IterBase.

Collaboration diagram for WvList< T >::Iter:

[legend]
List of all members.

Detailed Description

template<class T>
class WvList< T >::Iter

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 332 of file wvlinklist.h.

Public Member Functions

 Iter (const WvList &l)
 Binds the iterator to the specified list.
Tptr () const
 Returns a pointer to the current element.
 WvIterStuff (T)
void unlink ()
 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 ()
 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.
void rewind ()
 Rewinds the iterator to make it point to an imaginary element preceeding the first element of the list.
WvLinknext ()
 Moves the iterator along the list to point to the next element.
WvLinkcur () const
 Returns a pointer to the WvLink at the iterator's current location.
void * vptr () const
 Returns a void pointer to the object at the iterator's current location.
WvLinkfind (const void *data)
 Rewinds the iterator and repositions it over the element that matches the specified value.

Public Attributes

const WvListBaselist
WvLinklink
WvLinkprev


Constructor & Destructor Documentation

template<class T>
WvList< T >::Iter::Iter const WvList l  )  [inline]
 

Binds the iterator to the specified list.

"l" is the list

Definition at line 339 of file wvlinklist.h.


Member Function Documentation

WvLink* WvListBase::IterBase::cur  )  const [inline, inherited]
 

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 110 of file wvlinklist.h.

Referenced by WvHashTableBase::prevlink().

WvLink * WvListBase::IterBase::find const void *  data  )  [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.

It is not possible to use find(const void*) to locate multiple matching elements unless the list is altered between invocations since it always starts searching from the head of the list rather than from the current location.

Returns: the current WvLink pointer, or null if no such element was found

Definition at line 58 of file wvlinklist.cc.

References WvLink::data, WvListBase::IterBase::link, WvListBase::IterBase::next(), and WvListBase::IterBase::rewind().

WvLink* WvListBase::IterBase::next  )  [inline, inherited]
 

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 102 of file wvlinklist.h.

References WvLink::next.

Referenced by WvListBase::IterBase::find(), and WvHashTableBase::prevlink().

template<class T>
T* WvList< T >::Iter::ptr  )  const [inline]
 

Returns a pointer to the current element.

Returns: the element pointer, possibly null

Definition at line 346 of file wvlinklist.h.

References WvLink::data.

void WvListBase::IterBase::rewind  )  [inline, inherited]
 

Rewinds the iterator to make it point to an imaginary element preceeding the first element of the list.

Definition at line 89 of file wvlinklist.h.

Referenced by WvListBase::IterBase::find(), and WvHashTableBase::prevlink().

template<class T>
void WvList< T >::Iter::unlink  )  [inline]
 

Unlinks the current element from the list and automatically increments the iterator to point to the next element as if next() had been called.

Definition at line 356 of file wvlinklist.h.

References WvLink::next.

void* WvListBase::IterBase::vptr  )  const [inline, inherited]
 

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 117 of file wvlinklist.h.

References WvLink::data.

template<class T>
WvList< T >::Iter::WvIterStuff T   ) 
 

template<class T>
void WvList< T >::Iter::xunlink  )  [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 375 of file wvlinklist.h.


Member Data Documentation

WvLink* WvListBase::IterBase::link [inherited]
 

Definition at line 76 of file wvlinklist.h.

Referenced by WvListBase::IterBase::find().

const WvListBase* WvListBase::IterBase::list [inherited]
 

Definition at line 75 of file wvlinklist.h.

WvLink * WvListBase::IterBase::prev [inherited]
 

Definition at line 76 of file wvlinklist.h.


The documentation for this class was generated from the following file:
Generated on Wed Dec 15 15:08:20 2004 for WvStreams by  doxygen 1.3.9.1