Iterates over the key/value pairs in a dictionary.
More...
#include <jem/util/DictionaryEnumerator.h>
The abstract class DictionaryEnumerator
can be used to iterate over all key/value pairs in a Dictionary
. It extends the Enumerator
class with the member functions getKey()
and getValue()
that return the key and value, respectively, in a key/value pair.
A DictionaryEnumerator
points either to a key/value pair or to an end object that comes right after the last key/value pair. An end object is a conceptual object that can not be accessed. Only the function atEnd()
may be called when a DictionaryEnumerator
points to an end object.
- See also
Dictionary
virtual jem::util::DictionaryEnumerator::~DictionaryEnumerator |
( |
| ) |
|
|
protectedvirtual |
static Class* jem::util::DictionaryEnumerator::makeClass |
( |
| ) |
|
|
static |
static Class* jem::util::DictionaryEnumerator::getType |
( |
| ) |
|
|
static |
virtual Class* jem::util::DictionaryEnumerator::getClass |
( |
| ) |
const |
|
virtual |
Returns a pointer to the Class
instance representing the runtime class of this object. If T
denotes the runtime class of this object, then this function is equivalent with T::getType()
. The pointer is valid during the entire lifetime of the program.
- Returns
- A pointer to the
Class
instance representing the runtime class of this object.
Reimplemented from jem::util::Enumerator.
virtual Ref<Object> jem::util::DictionaryEnumerator::get |
( |
| ) |
const |
|
virtual |
Returns an object containing the key/value pair that this enumerator is currently pointing to. The dynamic type of the returned object is not specified. The only requirement is that the returned object can be passed to the function add()
of the dictionary that created this enumerator.
The implementation of this function provided by the DictionaryEnumerator
return the key/value pair as an ObjectPair
. That is, it executes the following code:
return newInstance<ObjectPair> (
);
This function may not be called when this enumerator points to the end object.
- Precondition
atEnd() == false
- Returns
- An object containing the current key/value pair.
Implements jem::util::Enumerator.
virtual String jem::util::DictionaryEnumerator::getKey |
( |
| ) |
const |
|
pure virtual |
Returns the key in the current key/value pair. This function may not be called when this enumerator points to the end object.
- Precondition
atEnd() == false
- Returns
- The key in the current key/value pair.
virtual Ref<Object> jem::util::DictionaryEnumerator::getValue |
( |
| ) |
const |
|
pure virtual |
Returns a reference to the value in the current key/value pair. This function may not be called when this enumerator points to the end object.
- Precondition
atEnd() == fale
- Returns
- A reference to the value in the current key/value pair.