JUCE
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
Public Member Functions
HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::Iterator Class Reference

Iterates over the items in a HashMap. More...

List of all members.

Public Member Functions

 Iterator (const HashMap &hashMapToIterate)
bool next ()
 Moves to the next item, if one is available.
KeyType getKey () const
 Returns the current item's key.
ValueType getValue () const
 Returns the current item's value.

Detailed Description

template<typename KeyType, typename ValueType, class HashFunctionToUse = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
class HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::Iterator

Iterates over the items in a HashMap.

To use it, repeatedly call next() until it returns false, e.g.

        HashMap <String, String> myMap;

        HashMap<String, String>::Iterator i (myMap);

        while (i.next())
        {
            DBG (i.getKey() << " -> " << i.getValue());
        }

The order in which items are iterated bears no resemblence to the order in which they were originally added!

Obviously as soon as you call any non-const methods on the original hash-map, any iterators that were created beforehand will cease to be valid, and should not be used.

See also:
HashMap

Constructor & Destructor Documentation

template<typename KeyType, typename ValueType, class HashFunctionToUse = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::Iterator::Iterator ( const HashMap hashMapToIterate)

Member Function Documentation

template<typename KeyType, typename ValueType, class HashFunctionToUse = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
bool HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::Iterator::next ( )

Moves to the next item, if one is available.

When this returns true, you can get the item's key and value using getKey() and getValue(). If it returns false, the iteration has finished and you should stop.

References HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::getNumSlots(), and Array< ElementType, TypeOfCriticalSectionToUse >::getUnchecked().

template<typename KeyType, typename ValueType, class HashFunctionToUse = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
KeyType HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::Iterator::getKey ( ) const

Returns the current item's key.

This should only be called when a call to next() has just returned true.

template<typename KeyType, typename ValueType, class HashFunctionToUse = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
ValueType HashMap< KeyType, ValueType, HashFunctionToUse, TypeOfCriticalSectionToUse >::Iterator::getValue ( ) const

Returns the current item's value.

This should only be called when a call to next() has just returned true.


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