Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTValHashDictionaryIterator<K,V>

Alternative interface: no Standard C++ Library

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <rw/tvhdict.h>
unsigned hashFun(const K&);
RWTValHashDictionary<K,V> dictionary(hashFun);
RWTValHashDictionaryIterator<K,V> iterator(dictionary);

Please Note!


If you do not have the Standard C++ Library, use the interface described here. Otherwise, use the interface to RWTValHashMapIterator described in the Class Reference.


Description

Iterator for class RWTValHashDictionary<K,V>, allowing sequential access to all keys and values of a parameterized hash dictionary. Elements are not accessed in any particular order.

Like all Rogue Wave 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.

Persistence

None

Example

#include<rw/tvhdict.h>
#include<iostream.h>
#include<rw/cstring.h>
int main(){
   RWTValHashDictionary<RWCString,int> age(RWCString::hash);
   RWTValHashDictionaryIterator<RWCString,int> itr(age);
   age.insert(RWCString("John"), 30);
   age.insert(RWCString("Steve"),17);
   age.insert(RWCString("Mark"),24);
//Duplicate insertion rejected
   age.insert(RWCString("Steve"),24);
   for(;itr();)
     cout << itr.key() << "\'s age is " << itr.value() << endl;
   return 0;
}
Program Output (not necessarily in this order)
John's age is 30
Steve's age is 17
Mark's age is 24

Public Constructor

RWTValHashDictionaryIterator(RWTValHashDictionary& c);

Public Operators

RWBoolean
operator++();
RWBoolean
operator()();

Public Member Functions

RWTValHashDictionary*
container() const;
K
key() const;
void
reset();
void
reset(RWTValHashDictionary& c);
V
value() const;


Previous fileTop of documentContentsIndexNext file
Return to the main class reference
©Copyright 1999, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.