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());
}
HashMap(int numberOfSlots=defaultHashTableSize, HashFunctionType hashFunction=HashFunctionType())
Creates an empty hash-map.
Definition juce_HashMap.h:136
#define DBG(textToWrite)
Writes a string to the standard error stream.
Definition juce_PlatformDefs.h:160
Iterates over the items in a HashMap.
Definition juce_HashMap.h:415
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
template<typename KeyType , typename ValueType , class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
bool HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::next |
( |
| ) |
|
|
noexcept |
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, HashFunctionType, TypeOfCriticalSectionToUse >::getNumSlots(), and Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::getUnchecked().
Referenced by HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::begin(), and HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::operator++().
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.
template<typename KeyType , typename ValueType , class HashFunctionType = DefaultHashFunctions, class TypeOfCriticalSectionToUse = DummyCriticalSection>
ValueType HashMap< KeyType, ValueType, HashFunctionType, TypeOfCriticalSectionToUse >::Iterator::getValue |
( |
| ) |
const |