casa
$Rev:20696$
|
Doubly linked constant list iterator. More...
#include <List.h>
Public Member Functions | |
ConstListIter (const List< t > *st) | |
This constructor creates a "ConstListIter" which tracks the "List<t>" parameter. | |
ConstListIter (const List< t > &st) | |
ConstListIter (const ConstListIter< t > &other) | |
This constructor creates a "ConstListIter" which tracks the same list tracked by the "ConstListIter<t>" parameter. | |
ConstListIter (const ConstListIter< t > *other) | |
ConstListIter () | |
This is the default constructor. | |
~ConstListIter () | |
void | notify (const Notice &) |
Hook through which NoticeTarget s are notified (by NoticeSource s). | |
Bool | atStart () const |
This functions allows one to checked if the cursor is at an extreme list position. | |
Bool | atEnd () const |
void | operator++ () |
This function is used to step the cursor forward through the list. | |
void | operator++ (int) |
void | operator-- () |
This function allow for stepping the cursor toward the front of the list. | |
void | operator-- (int) |
virtual uInt | pos (uInt) |
"pos()" without arguments returns the current postion of the cursor. | |
uInt | pos () const |
uInt | len () const |
This function returns the number of elements in the list. | |
uInt | step (Int offset) |
"step()" with no parameters advances the cursor forward one element. | |
uInt | step () |
const t & | getRight () const |
Returns the element to the right of the cursor. | |
virtual ConstListIter< t > & | operator= (const List< t > &other) |
This assignment operator substitutes the "List<t>" tracked by this iterator to the "List<t>" passed as an argument. | |
virtual ConstListIter< t > & | operator= (const List< t > *other) |
virtual ConstListIter< t > & | operator= (const ConstListIter< t > &other) |
This assignment operator substitutes the "List<t>" tracked by this iterator to the "List<t>" tracked by the passed "ConstListIter<t>" argument. | |
virtual ConstListIter< t > & | operator= (const ConstListIter< t > *other) |
void | toStart () |
This function moves the cursor to the beginning of the list. | |
void | toEnd () |
This function moves the cursor to the end of the list. | |
const List< t > * | container () const |
Get the container over which we are iterating, could be null... | |
Protected Attributes | |
Link< t > * | cur |
enum outside class because of compiler errors on HPUX enum {ConstListIterVersion = 1}; | |
Link< t > * | prev |
uInt | curPos |
List< t > * | container_ |
Doubly linked constant list iterator.
The List class above only provides for the list framework. This is one of two classes which allow list iteration, insertion, and removal. This class cannot be used to modify a list, but rather, it can only be used to look at or observe a list. It provides no functions for modifying the list.
All of the operations take place to the right of a conceptual cursor. The cursor starts out before the first element of the list and can be incremented past the last element of the list. Going further than the end of the list results in an exception.
In this example, assume that this function is called at the end of the example above, i.e. assume that the line before the return, above, is uncommented.
void iterate(ListIter<int> &list) { // List, conceptual // cursor = "|" ConstListIter<int> li = list; // 89 10 8 2 | li--; // 89 10 8 | 2 cout << li.getRight() << " "; // 89 10 8 | 2 li--; // 89 10 | 8 2 li.pos(0); // | 89 10 8 2 li.pos(3); // 89 10 8 | 2 li.pos(1); // 89 | 10 8 2 li.step(); // 89 10 | 8 2 li.pos(0); // | 89 10 8 2 li.step(-3); // 89 10 | 8 2 cout << li.getRight() << endl; // 89 10 | 8 2 cout << li << endl; // 89 10 | 8 2 }
The output which this function, iterate()
, would produce would look like:
2 8 len=4 pos=2 89 10 8 2
As shown above:
pos()
step()
, operator++()
, and operator--()
getRight()
In addition:
atStart()
, atEnd()
, and pos()
len()
Tip: This class uses the Notice classes to implement "dynamic" cursors so that multiple cursors are updated as elements are added and removed from the list;
casa::ConstListIter< t >::ConstListIter | ( | const List< t > * | st | ) |
This constructor creates a "ConstListIter" which tracks the "List<t>" parameter.
casa::ConstListIter< t >::ConstListIter | ( | const List< t > & | st | ) | [inline] |
casa::ConstListIter< t >::ConstListIter | ( | const ConstListIter< t > & | other | ) | [inline] |
casa::ConstListIter< t >::ConstListIter | ( | const ConstListIter< t > * | other | ) |
casa::ConstListIter< t >::ConstListIter | ( | ) | [inline] |
This is the default constructor.
It allows one to create an initially invalid empty ConstListIter. The instantiated class will accept assignment and thus become valid later.
casa::ConstListIter< t >::~ConstListIter | ( | ) |
Bool casa::ConstListIter< t >::atEnd | ( | ) | const [inline] |
Bool casa::ConstListIter< t >::atStart | ( | ) | const [inline] |
const List<t>* casa::ConstListIter< t >::container | ( | ) | const [inline] |
const t& casa::ConstListIter< t >::getRight | ( | ) | const [inline] |
Returns the element to the right of the cursor.
Reimplemented in casa::ListIter< t >, casa::ListIter< WCPositionEH * >, casa::ListIter< WorldCanvas * >, casa::ListIter< OrderedPair< key, val > >, casa::ListIter< DisplayEH * >, casa::ListIter< void * >, and casa::ListIter< WCMotionEH * >.
uInt casa::ConstListIter< t >::len | ( | ) | const [inline] |
void casa::ConstListIter< t >::notify | ( | const Notice & | ) | [virtual] |
Hook through which NoticeTarget
s are notified (by NoticeSource
s).
Implements casa::NoticeTarget.
Referenced by casa::ListIter< WCMotionEH * >::addRight().
void casa::ConstListIter< t >::operator++ | ( | ) | [inline] |
void casa::ConstListIter< t >::operator++ | ( | int | ) | [inline] |
void casa::ConstListIter< t >::operator-- | ( | ) | [inline] |
void casa::ConstListIter< t >::operator-- | ( | int | ) | [inline] |
virtual ConstListIter<t>& casa::ConstListIter< t >::operator= | ( | const List< t > & | other | ) | [virtual] |
This assignment operator substitutes the "List<t>" tracked by this iterator to the "List<t>" passed as an argument.
Reimplemented in casa::ListIter< t >, casa::ListIter< WCPositionEH * >, casa::ListIter< WorldCanvas * >, casa::ListIter< OrderedPair< key, val > >, casa::ListIter< DisplayEH * >, casa::ListIter< void * >, and casa::ListIter< WCMotionEH * >.
virtual ConstListIter<t>& casa::ConstListIter< t >::operator= | ( | const List< t > * | other | ) | [virtual] |
virtual ConstListIter<t>& casa::ConstListIter< t >::operator= | ( | const ConstListIter< t > & | other | ) | [virtual] |
This assignment operator substitutes the "List<t>" tracked by this iterator to the "List<t>" tracked by the passed "ConstListIter<t>" argument.
Reimplemented in casa::ListIter< t >, casa::ListIter< WCPositionEH * >, casa::ListIter< WorldCanvas * >, casa::ListIter< OrderedPair< key, val > >, casa::ListIter< DisplayEH * >, casa::ListIter< void * >, and casa::ListIter< WCMotionEH * >.
virtual ConstListIter<t>& casa::ConstListIter< t >::operator= | ( | const ConstListIter< t > * | other | ) | [virtual] |
virtual uInt casa::ConstListIter< t >::pos | ( | uInt | ) | [virtual] |
"pos()" without arguments returns the current postion of the cursor.
"pos()" with an unsigned integer parameter moves the cursor to an absolute position.
uInt casa::ConstListIter< t >::pos | ( | ) | const [inline] |
Definition at line 426 of file List.h.
Referenced by casa::ConstListIter< WCMotionEH * >::step().
uInt casa::ConstListIter< t >::step | ( | Int | offset | ) | [inline] |
uInt casa::ConstListIter< t >::step | ( | ) | [inline] |
Definition at line 455 of file List.h.
Referenced by casa::ConstListIter< WCMotionEH * >::step().
void casa::ConstListIter< t >::toEnd | ( | ) | [inline] |
void casa::ConstListIter< t >::toStart | ( | ) | [inline] |
List<t>* casa::ConstListIter< t >::container_ [protected] |
Definition at line 515 of file List.h.
Referenced by casa::ListIter< WCMotionEH * >::addRight(), and casa::ConstListIter< WCMotionEH * >::container().
Link<t>* casa::ConstListIter< t >::cur [protected] |
enum outside class because of compiler errors on HPUX enum {ConstListIterVersion = 1};
Definition at line 512 of file List.h.
Referenced by casa::ListIter< WCMotionEH * >::addRight(), casa::ConstListIter< WCMotionEH * >::atEnd(), casa::ConstListIter< WCMotionEH * >::getRight(), casa::ListIter< WCMotionEH * >::getRight(), casa::ConstListIter< WCMotionEH * >::operator++(), casa::ConstListIter< WCMotionEH * >::operator--(), casa::ConstListIter< WCMotionEH * >::toEnd(), and casa::ConstListIter< WCMotionEH * >::toStart().
uInt casa::ConstListIter< t >::curPos [protected] |
Definition at line 514 of file List.h.
Referenced by casa::ListIter< WCMotionEH * >::addRight(), casa::ConstListIter< WCMotionEH * >::operator++(), casa::ConstListIter< WCMotionEH * >::operator--(), casa::ConstListIter< WCMotionEH * >::pos(), casa::ConstListIter< WCMotionEH * >::step(), casa::ConstListIter< WCMotionEH * >::toEnd(), and casa::ConstListIter< WCMotionEH * >::toStart().
Link<t>* casa::ConstListIter< t >::prev [protected] |
Definition at line 513 of file List.h.
Referenced by casa::ListIter< WCMotionEH * >::addRight(), casa::ConstListIter< WCMotionEH * >::atStart(), casa::ConstListIter< WCMotionEH * >::operator++(), casa::ConstListIter< WCMotionEH * >::operator--(), casa::ConstListIter< WCMotionEH * >::toEnd(), and casa::ConstListIter< WCMotionEH * >::toStart().