mace::ConstMapIterator< M > Class Template Reference

#include <Iterator.h>

List of all members.


Detailed Description

template<typename M>
class mace::ConstMapIterator< M >

Java-style const iteration for C++ collections (next/hasNext).

implemented by always storing an iterator to the last item as well as the next (unretrieved) item. Calling next() advances the iterator, returning a reference to the item.

Example:

 mace::map<int, int> m;
 //insert a bunch of members into m
 mace::ConstMapIterator<mace::map<int, int> > i(m);
 while (i.hasNext()) {
   int& key;
   int& value = i.next(key);
   maceout << "Key " << key << " -> Value " << value << Log::endl;
 }

Definition at line 182 of file Iterator.h.


Public Member Functions

 ConstMapIterator (const M &s)
 Constructs the map iterator from a map reference (iterator over the whole map).
 ConstMapIterator (const M &s, const_iterator b)
 Constructs the map iterator from a map reference and a beginning point (iterates to end()).
 ConstMapIterator (const M &s, const_iterator b, const_iterator e)
 Constructs the map iterator from a map reference, a beginning point, and an ending point.
bool hasNext ()
 returns whether there are more elements
const V & next ()
 returns the present (next) item by const reference, advancing the iterators
const V & next (K &key)
 returns the present (next) item by const reference, and makes a copy of the key into the key reference, advancing the iterators

The documentation for this class was generated from the following file:

Generated on Sat Oct 4 21:30:38 2008 for Mace Library by  doxygen 1.5.5