casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
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 >

Public Member Functions

 ConstListIter (const List< t > *st)
 This constructor creates a "ConstListIter" which tracks the "List<t>" parameter. More...
 
 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. More...
 
 ConstListIter (const ConstListIter< t > *other)
 
 ConstListIter ()
 This is the default constructor. More...
 
 ~ConstListIter ()
 
void notify (const Notice &)
 Hook through which NoticeTargets are notified (by NoticeSources). More...
 
Bool atStart () const
 This functions allows one to checked if the cursor is at an extreme list position. More...
 
Bool atEnd () const
 
void operator++ ()
 This function is used to step the cursor forward through the list. More...
 
void operator++ (int)
 
void operator-- ()
 This function allow for stepping the cursor toward the front of the list. More...
 
void operator-- (int)
 
virtual uInt pos (uInt)
 "pos()" without arguments returns the current postion of the cursor. More...
 
uInt pos () const
 
uInt len () const
 This function returns the number of elements in the list. More...
 
uInt step (Int offset)
 "step()" with no parameters advances the cursor forward one element. More...
 
uInt step ()
 
const t & getRight () const
 Returns the element to the right of the cursor. More...
 
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. More...
 
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. More...
 
virtual ConstListIter< t > & operator= (const ConstListIter< t > *other)
 
void toStart ()
 This function moves the cursor to the beginning of the list. More...
 
void toEnd ()
 This function moves the cursor to the end of the list. More...
 
const List< t > * container () const
 Get the container over which we are iterating, could be null... More...
 
- Public Member Functions inherited from casacore::NoticeTarget
virtual ~NoticeTarget ()
 Destructs this NoticeTarget. More...
 
Bool isValid () const
 Returns a boolean value telling whether this NoticeTarget is still "valid". More...
 
Bool isAttached () const
 Returns a boolean value telling whether this NoticeTarget is still attached to a NoticeSource or not. More...
 
void invalidate ()
 Makes the current NoticeTarget "invalid". More...
 

Protected Attributes

Link< t > * cur
 
enum outside class because of compiler errors on HPUX

enum {ConstListIterVersion = 1}; More...

 
Link< t > * prev
 
uInt curPos
 
List< t > * container_
 
- Protected Attributes inherited from casacore::NoticeTarget
Link< NoticeTarget * > * ilink
 
NoticeSourcecontainer
 
Bool valid
 

Additional Inherited Members

- Protected Member Functions inherited from casacore::NoticeTarget
 NoticeTarget ()
 Creates an unlinked, "invalid" NoticeTarget. More...
 
 NoticeTarget (NoticeSource *v)
 Creates a "valid" NoticeTarget linked to the specified NoticeSource. More...
 
 NoticeTarget (NoticeSource &v)
 
 NoticeTarget (NoticeTarget &other)
 Creates a "valid" NoticeTarget linked to the same NoticeSource as the other NoticeTarget. More...
 
 NoticeTarget (NoticeTarget *other)
 
void unlink ()
 Unlinks this NoticeTarget from its NoticeSource. More...
 
void link (const NoticeTarget &other)
 Links this NoticeTarget to the same NoticeSource as the other NoticeTarget. More...
 
void link (const NoticeTarget *other)
 
Link< NoticeTarget * > * next ()
 Retrieves the next NoticeTarget in the target list of the associated NoticeSource. More...
 
const Link< NoticeTarget * > * next () const
 
void attach (NoticeSource *v)
 Adds this NoticeTarget to the target list in the specified NoticeSource, so that it will receive all notices sent out by that NoticeSource. More...
 
void attach (NoticeSource &v)
 

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 54 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 317 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 328 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 342 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 373 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 368 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 509 of file List.h.

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

Returns the element to the right of the cursor.

Definition at line 465 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 438 of file List.h.

template<class t>
void casacore::ConstListIter< t >::notify ( const Notice )
virtual
template<class t>
void casacore::ConstListIter< t >::operator++ ( )
inline

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

Definition at line 384 of file List.h.

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

Definition at line 392 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 406 of file List.h.

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

Definition at line 413 of file List.h.

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< casacore::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 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< casacore::OrderedPair< key, val > >.

template<class t>
virtual ConstListIter<t>& casacore::ConstListIter< t >::operator= ( const ConstListIter< t > *  other)
virtual
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 >::pos ( ) const
inline
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 450 of file List.h.

template<class t>
uInt casacore::ConstListIter< t >::step ( )
inline
template<class t>
void casacore::ConstListIter< t >::toEnd ( )
inline

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

Definition at line 499 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 492 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: