casacore::ConstListIter< t > Class Template Reference

Doubly linked constant list iterator. More...

#include <List.h>

Inheritance diagram for casacore::ConstListIter< t >:
casacore::NoticeTarget casacore::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 casacore::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 304 of file List.h.


Constructor & Destructor Documentation

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

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

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

Definition at line 314 of file List.h.

template<class t>
casacore::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 325 of file List.h.

template<class t>
casacore::ConstListIter< t >::ConstListIter ( const ConstListIter< t > *  other  ) 
template<class t>
casacore::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 339 of file List.h.

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

Member Function Documentation

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

Definition at line 370 of file List.h.

template<class t>
Bool casacore::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 365 of file List.h.

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

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

.\.

Definition at line 506 of file List.h.

template<class t>
const t& casacore::ConstListIter< t >::getRight (  )  const [inline]

Returns the element to the right of the cursor.

Reimplemented in casacore::ListIter< t >, and casacore::ListIter< OrderedPair< key, val > >.

Definition at line 462 of file List.h.

template<class t>
uInt casacore::ConstListIter< t >::len (  )  const [inline]

This function returns the number of elements in the list.

Definition at line 435 of file List.h.

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

Hook through which NoticeTargets are notified (by NoticeSources).

Implements casacore::NoticeTarget.

Referenced by casacore::ListIter< OrderedPair< key, val > >::addRight().

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

Definition at line 389 of file List.h.

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

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

Definition at line 381 of file List.h.

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

Definition at line 410 of file List.h.

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

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

Definition at line 403 of file List.h.

template<class t>
virtual ConstListIter<t>& casacore::ConstListIter< t >::operator= ( const ConstListIter< t > *  other  )  [virtual]
template<class t>
virtual ConstListIter<t>& casacore::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 casacore::ListIter< t >, and casacore::ListIter< OrderedPair< key, val > >.

template<class t>
virtual ConstListIter<t>& casacore::ConstListIter< t >::operator= ( const List< t > *  other  )  [virtual]
template<class t>
virtual ConstListIter<t>& casacore::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 casacore::ListIter< t >, and casacore::ListIter< OrderedPair< key, val > >.

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

Definition at line 427 of file List.h.

Referenced by casacore::ConstListIter< OrderedPair< key, val > >::step().

template<class t>
virtual uInt casacore::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 casacore::ConstListIter< t >::step (  )  [inline]

Definition at line 456 of file List.h.

Referenced by casacore::ConstListIter< OrderedPair< key, val > >::step().

template<class t>
uInt casacore::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 447 of file List.h.

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

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

Definition at line 496 of file List.h.

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

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

Definition at line 489 of file List.h.


Member Data Documentation

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

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1