casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Attributes
casa::ConstListIter< t > Class Template Reference

Doubly linked constant list iterator. More...

#include <List.h>

Inheritance diagram for casa::ConstListIter< t >:
casa::NoticeTarget casa::ListIter< t >

List of all members.

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 NoticeTargets are notified (by NoticeSources).
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_

Detailed Description

template<class t>
class casa::ConstListIter< t >

Doubly linked constant list iterator.

Synopsis

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.

Example

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()
allows for arbitrary positioning of the cursor
step(), operator++(), and operator--()
allow for relative positioning
getRight()
fetches the next element in the list.

In addition:

atStart(), atEnd(), and pos()
allow querying the position of the cursor
len()
returns the number of elements in the list.


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;

Definition at line 303 of file List.h.


Constructor & Destructor Documentation

template<class t>
casa::ConstListIter< t >::ConstListIter ( const List< t > *  st)

This constructor creates a "ConstListIter" which tracks the "List<t>" parameter.

template<class t>
casa::ConstListIter< t >::ConstListIter ( const List< t > &  st) [inline]

Definition at line 313 of file List.h.

template<class t>
casa::ConstListIter< t >::ConstListIter ( const ConstListIter< t > &  other) [inline]

This constructor creates a "ConstListIter" which tracks the same list tracked by the "ConstListIter<t>" parameter.

Definition at line 324 of file List.h.

template<class t>
casa::ConstListIter< t >::ConstListIter ( const ConstListIter< t > *  other)
template<class t>
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.

Definition at line 338 of file List.h.

template<class t>
casa::ConstListIter< t >::~ConstListIter ( )

Member Function Documentation

template<class t>
Bool casa::ConstListIter< t >::atEnd ( ) const [inline]

Definition at line 369 of file List.h.

template<class t>
Bool casa::ConstListIter< t >::atStart ( ) const [inline]

This functions allows one to checked if the cursor is at an extreme list position.

"atStart()" checks to see if the cursor is at the beginning of the list, and "atEnd()" checks to see if the cursor is at the end of the list.

Definition at line 364 of file List.h.

template<class t>
const List<t>* casa::ConstListIter< t >::container ( ) const [inline]

Get the container over which we are iterating, could be null...

Definition at line 505 of file List.h.

template<class t>
const t& casa::ConstListIter< t >::getRight ( ) const [inline]
template<class t>
uInt casa::ConstListIter< t >::len ( ) const [inline]

This function returns the number of elements in the list.

Definition at line 434 of file List.h.

template<class t>
void casa::ConstListIter< t >::notify ( const Notice ) [virtual]

Hook through which NoticeTargets are notified (by NoticeSources).

Implements casa::NoticeTarget.

Referenced by casa::ListIter< WCMotionEH * >::addRight().

template<class t>
void casa::ConstListIter< t >::operator++ ( ) [inline]

This function is used to step the cursor forward through the list.

Definition at line 380 of file List.h.

template<class t>
void casa::ConstListIter< t >::operator++ ( int  ) [inline]

Definition at line 388 of file List.h.

template<class t>
void casa::ConstListIter< t >::operator-- ( ) [inline]

This function allow for stepping the cursor toward the front of the list.

Definition at line 402 of file List.h.

template<class t>
void casa::ConstListIter< t >::operator-- ( int  ) [inline]

Definition at line 409 of file List.h.

template<class t>
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 * >.

template<class t>
virtual ConstListIter<t>& casa::ConstListIter< t >::operator= ( const List< t > *  other) [virtual]
template<class t>
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 * >.

template<class t>
virtual ConstListIter<t>& casa::ConstListIter< t >::operator= ( const ConstListIter< t > *  other) [virtual]
template<class t>
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.

template<class t>
uInt casa::ConstListIter< t >::pos ( ) const [inline]

Definition at line 426 of file List.h.

Referenced by casa::ConstListIter< WCMotionEH * >::step().

template<class t>
uInt casa::ConstListIter< t >::step ( Int  offset) [inline]

"step()" with no parameters advances the cursor forward one element.

"step()" with a signed integer parameter moves the cursor (forward or backward) by a relative offset indicated by the parameter.

Definition at line 446 of file List.h.

template<class t>
uInt casa::ConstListIter< t >::step ( ) [inline]

Definition at line 455 of file List.h.

Referenced by casa::ConstListIter< WCMotionEH * >::step().

template<class t>
void casa::ConstListIter< t >::toEnd ( ) [inline]

This function moves the cursor to the end of the list.

Definition at line 495 of file List.h.

template<class t>
void casa::ConstListIter< t >::toStart ( ) [inline]

This function moves the cursor to the beginning of the list.

Definition at line 488 of file List.h.


Member Data Documentation

template<class t>
List<t>* casa::ConstListIter< t >::container_ [protected]
template<class t>
Link<t>* casa::ConstListIter< t >::cur [protected]
template<class t>
uInt casa::ConstListIter< t >::curPos [protected]
template<class t>
Link<t>* casa::ConstListIter< t >::prev [protected]

The documentation for this class was generated from the following file: