Jive reference manual
|
Iterates over a set of objects. More...
Public Member Functions | |
virtual Class * | getClass () const |
Returns the Class instance representing the runtime class of this object. More... | |
virtual bool | atEnd () const =0 |
Checks whether this enumerator points to an end object. More... | |
virtual void | toNext ()=0 |
Advances this enumerator to the next object. More... | |
virtual Ref< Object > | get () const =0 |
Returns the current object. More... | |
Public Member Functions inherited from jem::Object | |
virtual String | toString () const |
Returns a short textual description of this object. More... | |
virtual long | hashValue () const |
Returns a hash value for this object. More... | |
virtual bool | equals (const Ref< Object > &obj) const |
Tests whether two objects are equal. More... | |
Ref< Object > | clone () const |
Returns a copy of this object. More... | |
Static Public Member Functions | |
static Class * | makeClass () |
static Class * | getType () |
Static Public Member Functions inherited from jem::Object | |
static Class * | getType () |
Returns the Class instance representing the Object class. More... | |
Protected Member Functions | |
virtual | ~Enumerator () |
Protected Member Functions inherited from jem::Collectable | |
Collectable () | |
Creates an empty Collectable . More... | |
~Collectable () | |
Frees resources. More... | |
#include <jem/util/Enumerator.h>
The abstract class Enumerator
can be used to iterate over a collection of objects. An Enumerator
can be viewed as a type of forward iterator with virtual member functions.
An Enumerator
either points to an object in a collection, or to a special end object that is located one position past the last object in the collection. The member function atEnd()
can be used to check whether an enumerator points to a regular object or to an end object. Note that end objects can not be accessed; they are conceptual objects that are not physically stored in memory.
The following code fragment demonstrates how the Enumerator
class is typically used.
Enumerable
|
protectedvirtual |
|
static |
|
static |
|
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.
Class
instance representing the runtime class of this object. Reimplemented from jem::Object.
Reimplemented in jem::util::DictionaryEnumerator.
|
pure virtual |
Checks whether this enumerator points to an end object that marks the end of an object collection.
true
if this enumerator points to an end object, or false
otherwise.
|
pure virtual |
Advances this enumerator to the next object in the collection, or to the end object if there is no next object. This function may not be called if this enumerator already points to the end object.
this->atEnd() == false
Implemented in jem::util::SequenceEnumerator.
Returns a reference to the object that this enumerator is currently pointing to. This function may not be called if this enumerator is pointing to an end object.
this->atEnd() == false
Implemented in jem::util::DictionaryEnumerator, and jem::util::MapEnumerator.