WvVector< T >::Iter Class Reference

#include <wvvector.h>

Inheritance diagram for WvVector< T >::Iter:

[legend]
List of all members.

Detailed Description

template<class T>
class WvVector< T >::Iter

A simple iterator that walks through all elements in the list.

Definition at line 350 of file wvvector.h.

Public Member Functions

 Iter (const WvVector &v)
 Binds the iterator to the specified vector.
T * ptr () const
 Returns a pointer to the current element.
 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 remove (bool destroy=true)
 Remove the current element from the vector and automatically increments the iterator to point to the next element as if next() had been called.
void xremove (bool destroy=true)
 Removes the current element from the vector but unlike remove() automatically returns the iterator to the previous item in the vector 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 vector.
void unwind ()
 Unwinds the iterator to make it point to the last element of the vector.
WvLinknext ()
 Moves the iterator along the vector to point ot the next element.
WvLinkprev ()
 Moves the iterator along the vector to point ot the next element.
WvLinkcur () const
 Returns a pointer to the current WvLink at the iterator's current location.
WvLinkfind (const void *data)
 Rewinds the iterator and repositions it over the element that matches the specified value.
WvLinkfind_next (const void *data)
 Repositions the iterator over the element that matches the specified value.

Protected Attributes

const WvVectorBasevec
int i
WvLinklink

Friends

class WvVectorBase


Member Function Documentation

template<class T>
void WvVector< T >::Iter::xremove ( bool  destroy = true  )  [inline]

Removes the current element from the vector but unlike remove() automatically returns the iterator to the previous item in the vector such that next() must be called to obtain the next element.

This version allows for writing neater loop structures since an element can be removed in mid-traversal while still allowing the iterator to be incremented at the top of the loop as usual.

Calling xremove() twice in a row is currently unsupported.

Definition at line 405 of file wvvector.h.

References WvVectorBase::IterBase::i, and WvVectorBase::IterBase::prev().

WvLink* WvVectorBase::IterBase::next (  )  [inline, inherited]

Moves the iterator along the vector to point ot 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 174 of file wvvector.h.

References WvVectorBase::IterBase::i, WvVectorBase::IterBase::link, WvVectorBase::IterBase::vec, WvVectorBase::xcount, and WvVectorBase::xseq.

Referenced by WvVectorBase::IterBase::find(), and WvVectorBase::IterBase::find_next().

WvLink* WvVectorBase::IterBase::prev (  )  [inline, inherited]

Moves the iterator along the vector to point ot the next element.

Returns: the current WvLink pointer, or null if there were no more elements remaining in the traversal sequence

Definition at line 191 of file wvvector.h.

References WvVectorBase::IterBase::i, WvVectorBase::IterBase::vec, and WvVectorBase::xseq.

Referenced by WvVector< T >::Iter::xremove().

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

Returns a pointer to the current WvLink at the iterator's current location.

Returns: the current WvLink pointer, or null if there were no more elements remain.

Definition at line 206 of file wvvector.h.

References WvVectorBase::IterBase::link.

Referenced by WvVector< T >::Iter::ptr().

WvLink * WvVectorBase::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.

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 72 of file wvvector.cc.

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

WvLink * WvVectorBase::IterBase::find_next ( const void *  data  )  [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 82 of file wvvector.cc.

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


The documentation for this class was generated from the following file:
Generated on Mon Feb 5 10:54:42 2007 for WvStreams by  doxygen 1.5.1