casacore
|
Const associative array iterator. More...
#include <Map.h>
Public Types | |
enum | { ConstMapIterVersion } |
Public Member Functions | |
virtual void | toStart () |
Move the iterator to the start of the Map. More... | |
virtual void | operator++ () |
Advance to the next element of the Map. More... | |
virtual void | operator++ (int) |
virtual const key & | getKey () const |
Get the key or value for the current position in the Map. More... | |
virtual const value & | getVal () const |
virtual Bool | atEnd () const |
Check to see if the iterator position is at the end or beginning of the Map. More... | |
virtual Bool | atStart () const |
virtual Bool | isValid () const |
Check to see if the iterator is in a valid state. More... | |
ConstMapIter (const Map< key, value > *st) | |
Constructs a Map iterator from a Map (with reference semantics). More... | |
ConstMapIter (const Map< key, value > &st) | |
virtual ConstMapIter< key, value > & | operator= (const Map< key, value > &other) |
Assign one map iterator to a map (with reference semantics). More... | |
virtual ConstMapIter< key, value > & | operator= (const Map< key, value > *other) |
ConstMapIter (const ConstMapIter< key, value > *st) | |
Constructs a Map iterator from another iterator (with reference semantics). More... | |
ConstMapIter (const ConstMapIter< key, value > &st) | |
virtual ConstMapIter< key, value > & | operator= (const ConstMapIter< key, value > &other) |
Assign one map iterator to another iterator (with reference semantics). More... | |
virtual ConstMapIter< key, value > & | operator= (const ConstMapIter< key, value > *other) |
ConstMapIter () | |
Default constructor creates an invalid Map iterator. More... | |
const value & | defaultVal () const |
Returns the default value for the Map on which this iterator is operating if it is a valid iterator, otherwise it throws an exception. More... | |
const value & | operator() (const key &ky) const |
Allows mapping functions to be performed with the map on which this iterator operates. More... | |
const value * | isDefined (const key &ky) const |
Allows one to check to see if a given key is defined in the map which this iterator tracks. More... | |
uInt | ndefined () const |
Returns the number of user defined mappings. More... | |
const Map< key, value > & | container () const |
Returns the container on which this iterator is operating. More... | |
virtual | ~ConstMapIter () |
Protected Member Functions | |
ConstMapIter (MapIterRep< key, value > *st) | |
Dummy used to initialization by derived classes. More... | |
void | SetRep (MapIterRep< key, value > *st) |
Always DELETES Rep if necessary. More... | |
Protected Attributes | |
MapIterRep< key, value > * | Rep |
Const associative array iterator.
This class implements the mechanism for traversing constant associative arrays, i.e. "Map"s. This allows one to move the cursor to the beginning of the map and serially traverse the map. The key and value elements can be extracted at each position in the Map. For example: template<class key,class value> void print(const Map<key,value> &xx){ ConstMapIter<key,value> x(xx); x.toStart(); while (!x.atEnd()) { cout << "(" << x.getKey() << "," << x.getVal() << ")" << " "; x++; } cout << endl; }
This example declares a templated function which accepts a const Map as a parameter, and iterates through the map displaying the key/value pairs at each positon.
anonymous enum |
casacore::ConstMapIter< key, value >::ConstMapIter | ( | const Map< key, value > * | st | ) |
casacore::ConstMapIter< key, value >::ConstMapIter | ( | const Map< key, value > & | st | ) |
casacore::ConstMapIter< key, value >::ConstMapIter | ( | const ConstMapIter< key, value > * | st | ) |
Constructs a Map iterator from another iterator (with reference semantics).
casacore::ConstMapIter< key, value >::ConstMapIter | ( | const ConstMapIter< key, value > & | st | ) |
|
inline |
|
virtual |
|
inlineprotected |
|
virtual |
Check to see if the iterator position is at the end or beginning of the Map.
|
virtual |
const Map<key,value>& casacore::ConstMapIter< key, value >::container | ( | ) | const |
Returns the container on which this iterator is operating.
const value& casacore::ConstMapIter< key, value >::defaultVal | ( | ) | const |
Returns the default value for the Map on which this iterator is operating if it is a valid iterator, otherwise it throws an exception.
Referenced by casacore::MapIter< key, value >::defaultVal().
|
virtual |
Get the key or value for the current position in the Map.
|
virtual |
Reimplemented in casacore::MapIter< key, value >.
const value* casacore::ConstMapIter< key, value >::isDefined | ( | const key & | ky | ) | const |
Allows one to check to see if a given key is defined in the map which this iterator tracks.
If this iterator is invalid, then an exception will be thrown.
Referenced by casacore::MapIter< key, value >::isDefined().
|
virtual |
Check to see if the iterator is in a valid state.
Referenced by casacore::MapIter< key, value >::clear(), casacore::MapIter< key, value >::defaultVal(), casacore::MapIter< key, value >::define(), casacore::MapIter< key, value >::isDefined(), casacore::MapIter< key, value >::operator()(), and casacore::MapIter< key, value >::remove().
uInt casacore::ConstMapIter< key, value >::ndefined | ( | ) | const |
Returns the number of user defined mappings.
const value& casacore::ConstMapIter< key, value >::operator() | ( | const key & | ky | ) | const |
Allows mapping functions to be performed with the map on which this iterator operates.
If this iterator is invalid, then an exception will be thrown.
Referenced by casacore::MapIter< key, value >::operator()().
|
virtual |
Advance to the next element of the Map.
|
virtual |
|
virtual |
Assign one map iterator to a map (with reference semantics).
Reimplemented in casacore::MapIter< key, value >.
|
virtual |
Reimplemented in casacore::MapIter< key, value >.
|
virtual |
Assign one map iterator to another iterator (with reference semantics).
Reimplemented in casacore::MapIter< key, value >.
|
virtual |
Reimplemented in casacore::MapIter< key, value >.
|
inlineprotected |
Always DELETES Rep if necessary.
Definition at line 567 of file Map.h.
References casacore::ConstMapIter< key, value >::Rep.
|
virtual |
Move the iterator to the start of the Map.
|
protected |
Definition at line 557 of file Map.h.
Referenced by casacore::MapIter< key, value >::clear(), casacore::MapIter< key, value >::container(), casacore::MapIter< key, value >::defaultVal(), casacore::MapIter< key, value >::define(), casacore::MapIter< key, value >::isDefined(), casacore::MapIter< key, value >::operator()(), casacore::MapIter< key, value >::remove(), and casacore::ConstMapIter< key, value >::SetRep().