Public Member Functions | List of all members
HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator Struct Reference

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

Public Member Functions

 Iterator (const HashMap &hashMapToIterate) noexcept
 
 Iterator (const Iterator &other) noexcept
 
bool next () noexcept
 Moves to the next item, if one is available. More...
 
KeyType getKey () const
 Returns the current item's key. More...
 
ValueType getValue () const
 Returns the current item's value. More...
 
void reset () noexcept
 Resets the iterator to its starting position. More...
 
Iteratoroperator++ () noexcept
 
ValueType operator* () const
 
bool operator!= (const Iterator &other) const noexcept
 
void resetToEnd () noexcept
 

Detailed Description

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

Iterates over the items in a HashMap.

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

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

The order in which items are iterated bears no resemblance 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

◆ Iterator() [1/2]

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

◆ Iterator() [2/2]

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::Iterator ( const Iterator other)
noexcept

Member Function Documentation

◆ next()

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

◆ getKey()

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

Returns the current item's key.

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

◆ getValue()

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

Returns the current item's value.

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

Referenced by HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::operator*().

◆ reset()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
void HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::reset ( )
noexcept

Resets the iterator to its starting position.

◆ operator++()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
Iterator& HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::operator++ ( )
noexcept

◆ operator*()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
ValueType HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::operator* ( ) const

◆ operator!=()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
bool HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::operator!= ( const Iterator other) const
noexcept

◆ resetToEnd()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
void HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::resetToEnd ( )
noexcept

The documentation for this struct was generated from the following file:
HashMap
Holds a set of mappings between some key/value pairs.
Definition: juce_HashMap.h:106
HashMap::Iterator
Iterates over the items in a HashMap.
Definition: juce_HashMap.h:402
DBG
#define DBG(textToWrite)
Writes a string to the standard error stream.
Definition: juce_PlatformDefs.h:148