Tools.h++ Manual
22-36 104011 Tandem Computers Incorporated
22
RWTPtrHashDictionaryIterator<K,V>
Synopsis
#include <rw/tphdict.h>
unsigned hashFun(const K&);
RWTPtrHashDictionary<KV> dictionary(hashFun);
RWTPtrHashDictionaryIterator<KV> iterator(dictionary);
Description Iterator for class
RWTPtrHashDictionary<KV>
, allowing sequential access to
all keys and values of a parameterized hash dictionary. Elements are not
accessed in any particular order.
Like all Tools.h++ iterators, the "current item" is undefined immediately after
construction—you must define it by using
operator()
or some other (valid)
operation.
Once the iterator has advanced beyond the end of the collection it is no longer
valid—continuing to use it will bring undefined results.
Public constructor
RWTPtrHashDictionaryIterator(RWTPtrHashDictionary& c);
Constructs an iterator to be used with the dictionary
c
.
Public operators
RWBoolean operator++();
Advances the iterator to the next key-value pair and returns
TRUE
. When the
end of the collection is reached, returns
FALSE
and the position of the iterator
will be undefined.
K* operator()();
Advances the iterator to the next key-value pair and returns a pointer to the
key. When the end of the collection is reached, returns nil and the position of
the iterator will be undefined. Use member function
value()
to recover the
dictionary value.