Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

RWTPtrHashTableIterator<T>

Alternative interface: no Standard C++ Library

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

Synopsis

#include <rw/tphasht.h>
RWTPtrHashTable<T> table;
RWTPtrHashTableIterator<T> iterator(table);

Please Note!


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


Description

Iterator for class RWTPtrHashTable<T>, allowing sequential access to all the elements of a hash table. 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/tphasht.h>
#include<iostream.h>
#include<rw/cstring.h>

int main(){
   RWTPtrHashTable<RWCString> age(RWCString::hash);

   RWTPtrHashTableIterator
   <RWCString> itr(age);

   age.insert(new RWCString("John"));
   age.insert(new RWCString("Steve"));
   age.insert(new RWCString("Mark"));
   age.insert(new RWCString("Steve"));

   for(;++itr;)
     cout << *itr.key() << endl;

   return 0;
}

Program Output (not necessarily in this order)
John
Mark
Steve
Steve

Public Constructor

RWTPtrHashTableIterator(RWTPtrHashTable<T>& c);

Public Operators

RWBoolean
operator++();
T*
operator()();

Public Member Functions

RWTPtrHashTable<T>*
container() const;
T*
key() const;
void
reset();
void
reset(RWTPtrHashTable<T>& c);


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.