Step through a non-const HashMap. More...
#include <HashMapIter.h>
Public Member Functions | |
| val & | getVal () |
| Get the key or value for the current position in the Map. | |
| virtual const val & | getVal () const |
| val & | define (const key &k, const val &v) |
| These functions allow for the definition and removal of key/value relations. | |
| void | remove (const key &k) |
| const val & | defaultVal () const |
| This returns the default value for the map that this iterator is tracking. | |
| val & | defaultVal () |
| void | clear () |
| Clear all of the mappings. | |
| const val & | operator() (const key &ky) const |
| Allows mapping functions to be performed with the map on which this iterator operates. | |
| val & | operator() (const key &ky) |
| HashMapIter (HashMap< key, val > &st) | |
| This allows a MapIter to be constructed from a Map. | |
| HashMapIter (const HashMapIter< key, val > &other) | |
| This allows a MapIter to be constructed from another MapIter. | |
| HashMapIter () | |
| Default constructor creates an invalid Map iterator. | |
| virtual HashMapIter< key, val > & | operator= (HashMap< key, val > &other) |
| This assignment operator allows the Map which this MapIter tracks to be changed. | |
| virtual HashMapIter< key, val > & | operator= (const HashMapIter< key, val > &other) |
| This assignment operator allows the Map which this MapIter tracks to be changed. | |
| HashMap< key, val > & | container () |
| Returns the container on which this iterator is operating. | |
| const HashMap< key, val > & | container () const |
| Returns the container on which this iterator is operating. | |
| ~HashMapIter () | |
| dtor | |
Protected Member Functions | |
| ConstHashMapIter< key, val > & | operator= (const HashMap< key, val > &) |
| Assign one map iterator to a map (with reference semantics). | |
| ConstHashMapIter< key, val > & | operator= (const ConstHashMapIter< key, val > &) |
Step through a non-const HashMap.
Public interface
This class is an iterator, and it used to step through non-const HashMap s. This is useful when one wishes to find each of the user defined mappings in a particular map.
#include <aips/Containers/HashMap.h> #include <casacore/casa/BasicSL/String.h> #include <iostream> main() { HashMap<String,Int> hash; hash.define("one",1); hash.define("two",2); hash.define("three",3); hash.define("four",4); hash.define("five",5); hash.define("six",6); HashMapIter<String,Int> iter(hash); for ( iter.toStart(); ! iter.atEnd(); iter++ ) cout << iter.getVal() << ": " << iter.getKey() << endl; }
Same as ConstHashMapIter , but allows for modification of the underlying structure.
Definition at line 254 of file HashMapIter.h.
| casacore::HashMapIter< key, val >::HashMapIter | ( | HashMap< key, val > & | st | ) | [inline] |
| casacore::HashMapIter< key, val >::HashMapIter | ( | const HashMapIter< key, val > & | other | ) | [inline] |
| casacore::HashMapIter< key, val >::HashMapIter | ( | ) | [inline] |
Default constructor creates an invalid Map iterator.
Definition at line 348 of file HashMapIter.h.
| casacore::HashMapIter< key, val >::~HashMapIter | ( | ) |
dtor
| void casacore::HashMapIter< key, val >::clear | ( | ) | [inline] |
Clear all of the mappings.
Definition at line 305 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
| const HashMap<key,val>& casacore::HashMapIter< key, val >::container | ( | ) | const [inline] |
Returns the container on which this iterator is operating.
Reimplemented from casacore::ConstHashMapIter< key, val >.
Definition at line 376 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
| HashMap<key,val>& casacore::HashMapIter< key, val >::container | ( | ) | [inline] |
Returns the container on which this iterator is operating.
Definition at line 371 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
| val& casacore::HashMapIter< key, val >::defaultVal | ( | ) | [inline] |
Definition at line 295 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
| const val& casacore::HashMapIter< key, val >::defaultVal | ( | ) | const [inline] |
This returns the default value for the map that this iterator is tracking.
With a non-const iterator the default value can be changed.
Reimplemented from casacore::ConstHashMapIter< key, val >.
Definition at line 291 of file HashMapIter.h.
| val& casacore::HashMapIter< key, val >::define | ( | const key & | k, | |
| const val & | v | |||
| ) | [inline] |
These functions allow for the definition and removal of key/value relations.
The "define(key &, value &)" function defines a key/value relation, and "remove(key &)" function removes a relation if it has been previously defined.
Definition at line 273 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
| virtual const val& casacore::HashMapIter< key, val >::getVal | ( | ) | const [virtual] |
Reimplemented from casacore::ConstHashMapIter< key, val >.
| val& casacore::HashMapIter< key, val >::getVal | ( | ) |
Get the key or value for the current position in the Map.
| val& casacore::HashMapIter< key, val >::operator() | ( | const key & | ky | ) | [inline] |
Definition at line 322 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
| const val& casacore::HashMapIter< key, val >::operator() | ( | const key & | ky | ) | const [inline] |
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. With a non-const operator, the value can be changed.
Reimplemented from casacore::ConstHashMapIter< key, val >.
Definition at line 318 of file HashMapIter.h.
| ConstHashMapIter<key,val>& casacore::HashMapIter< key, val >::operator= | ( | const ConstHashMapIter< key, val > & | ) | [inline, protected] |
Definition at line 397 of file HashMapIter.h.
References casacore::throw_hashmapiter_init_error().
| ConstHashMapIter<key,val>& casacore::HashMapIter< key, val >::operator= | ( | const HashMap< key, val > & | other | ) | [inline, protected, virtual] |
Assign one map iterator to a map (with reference semantics).
Reimplemented from casacore::ConstHashMapIter< key, val >.
Definition at line 394 of file HashMapIter.h.
References casacore::throw_hashmapiter_init_error().
| virtual HashMapIter<key,val>& casacore::HashMapIter< key, val >::operator= | ( | const HashMapIter< key, val > & | other | ) | [virtual] |
| virtual HashMapIter<key,val>& casacore::HashMapIter< key, val >::operator= | ( | HashMap< key, val > & | other | ) | [virtual] |
| void casacore::HashMapIter< key, val >::remove | ( | const key & | k | ) | [inline] |
Definition at line 278 of file HashMapIter.h.
References casacore::ConstHashMapIter< key, val >::Container, casacore::ConstHashMapIter< key, val >::isValid(), and casacore::throw_invalid_hashmapiter_error().
1.6.1