Xavax C++ Library Class Index   FAQ   Overview

Class xavax::DListIterator<T>

DListIterator<T> is the iterator template for DList<T>.

Constructor Summary
DListIterator(DList<T>& list)
         Construct an iterator for list.
DListIterator(const DListIterator<T>& src)
         Construct a new iterator that is a copy of src.

Operator Summary
DListIterator<T>& operator=(DListIterator<T>& src)
         Modify this iterator to point to the same list and element as src.
T* operator()()
         Return the current element.
T* operator++()
         Advance the cursor and return the current element (preincrement).
T* operator++(int)
         Advance the cursor and return the current element (postincrement).
T* operator--()
Backup the cursor and return the current element (predecrement).
T* operator--(int)
         Backup the cursor and return the current element (postdecrement).

Method Summary
bool active()
         Return true if the cursor is active.
void append(const T& t)
         Append a new element after the current element.
bool atFirst()
         Return true if the cursor is at the first element.
bool atLast()
         Return true if the cursor is at the last element.
bool done()
         Return true if the cursor is not active.
void insert(const T& t)
         Insert a new element before the current element.
DList<T>& list()
         Return the list to which this iterator is associated.
T remove()
         Remove and return the current element.
void reset()
         Reset the cursor to the first element in the list.
void reset(DList<T>& list)
         Associate the iterator with a new list and reset the cursor to the first element in the list.
void seek(size_t p)
         Move the cursor to the element at position p in the list.

Related Classes
DList<T>.

Constructor Detail

DListIterator<T>

DListIterator<T>(DList<T>&list)
Construct an iterator and associate it with list. Position the cursor at the first element in list.

DListIterator<T>

DListIterator<T>(const DListIterator<T>& src)
Construct an iterator and associate it with the same list and element as src.
Parameters:
src - the list to copy.

Operator Detail

operator=

DListIterator<T>& operator=(DListIterator<T>& src)
Associate this iterator with the same list and element as src.
Parameters:
src - the iterator to copy.

operator()

T* operator()()
Return a pointer to the current element.
Returns:
a pointer to the current element.

operator++

T* operator++()
Advance the cursor to the next element and return a pointer to that element. This is the prefix form of operator++.
Returns:
a pointer to the next element.

operator++

T* operator++(int)
Return a pointer to the current element and advance the cursor to the next element. This is the postfix form of operator++.
Returns:
a pointer to the current element.

operator--

T* operator--()
Back up the cursor to the previous element and return a pointer to that element. This is the prefix form of operator--.
Returns:
a pointer to the previous element.

operator--

T* operator--(int)
Return a pointer to the current element and back up the cursor to the previous element. This is the postfix form of operator--.
Returns:
a pointer to the current element.

Method Detail

active

bool active() const
Return true if the cursor is active (pointing at an element).
Returns:
true if the cursor is active.

append

void append(const T& t)
Append a new element after the current element. The cursor is not modified.
Parameters:
t - the object to be appended.

atFirst

bool atFirst() const
Return true if the cursor is at the first element in the list.
Returns:
true if the cursor is at the first element.

atLast

bool atLast() const
Return true if the cursor is at the last element in the list.
Returns:
true if the cursor is at the last element.

done

bool done() const
Return true if the cursor is not active (not pointing at an element).
Returns:
true if the cursor is not active.

insert

void insert(const T& t)
Insert a new element before the current element. The cursor is not modified.
Parameters:
t - the object to be inserted.

list

DList<T>& list() const
Return the list to which this iterator is associated.
Returns:
the associated list.

remove

T remove()
Remove and return the current element.
Returns:
the current element.

reset

void reset()
Reset the cursor to the first element in the list.

reset

void reset(DList<T>& list)
Associate this iterator with a new list and reset the cursor to point to the first element.
Parameters:
list - the new list.

seek

void seek(size_t p)
Advance the cursor to position p in the list.
Parameters:
p - the new position for the cursor.

Example Code

Copyright © 2003 Xavax Inc. -- All Rights Reserved