-
template
class
PortableHashtableIterator<class KeyType, class ValueType>
(Return to index)
-
This class is an iterator object, used for iterating over the set
of keys or values in a PortableHashtable.
Type:
Include file:
../../hashtable/PortableHashtable.h
Note that it is illegal to modify the hashtable during an iteration
traversal (an assertion failure will occur if you try it, and your
program will exit)
Given a PortableHashtable object, you can obtain one or more of these
iterator objects by calling the PortableHashtable's GetIterator() method.
This iterator actually contains separate state for two iterations:
one for iterating over the values in the PortableHashtable, and one for
iterating over the keys. These two iterations can be done independently
of each other.
Synopsis:
Public methods:
- public KeyType *
GetNextKey ()
As above, but returns a pointer to the key object, or NULL if none are left.
(Be careful, the returned pointer may become invalid when the hashtable is modified)
- public bool
GetNextKey (KeyType & setNextKey)
If there are more keys left in the key traversal, copies the next one into
(setNextKey) and returns true. Otherwise, returns false.
- public ValueType *
GetNextValue ()
As above, but returns a pointer to the next value object, or NULL if none are left.
(Be careful, the returned pointer may become invalid when the hashtable is modified)
- public bool
GetNextValue (ValueType & setNextValue)
If there are more values left in the values traversal, copies the next one into
(setNextValue) and returns true. Otherwise, returns false.
- public bool
HasMoreKeys () const
Returns true iff there are more keys left in the key traversal.
- public bool
HasMoreValues () const
Returns true iff there are more values left in the value traversal.
- public KeyType *
PeekNextKey () const
As above, but returns a pointer to the key object, or NULL if none left.
(Be careful, the returned pointer may become invalid when the hashtable is modified)
- public bool
PeekNextKey (KeyType & setKey) const
Copies the next key in the key traversal into (setKey) without modifying
the state of the traversal. Returns false iff there are no more keys left.
- public ValueType *
PeekNextValue () const
As above, but returns a pointer to the next value object, or NULL if none are left.
(Be careful, the returned pointer may become invalid when the hashtable is modified)
- public bool
PeekNextValue (ValueType & setKey) const
Copies the next value in the value traversal into (setValue) without modifying
the state of the traversal. Returns false iff there are no more values left.
- public
PortableHashtableIterator ()
Default constructor. It's here only so that you can include PortableHashtableIterators
as member variables, in arrays, etc. PortableHashtableIterators created with this
constructor are "empty", so they won't be useful until you set them equal to a
PortableHashtableIterator that was returned by PortableHashtable::GetIterator().
Friend methods: