LMMS
Loading...
Searching...
No Matches
water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator Struct Reference

#include <HashMap.h>

Public Member Functions

 Iterator (const HashMap &hashMapToIterate) noexcept
 Iterator (const Iterator &other) noexcept
bool next () noexcept
KeyType getKey () const
ValueType getValue () const
void reset () noexcept
Iteratoroperator++ () noexcept
ValueType operator* () const
bool operator!= (const Iterator &other) const noexcept
void resetToEnd () noexcept

Private Attributes

const HashMaphashMap
HashEntryentry
int index

Detailed Description

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
struct water::HashMap< KeyType, ValueType, HashFunctionType >::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())
Definition HashMap.h:118
register unsigned i
Definition inflate.c:1575
#define DBG(textToWrite)
Definition HashMap.h:359

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

◆ Iterator() [1/2]

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::Iterator ( const HashMap & hashMapToIterate)
inlinenoexcept

◆ Iterator() [2/2]

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::Iterator ( const Iterator & other)
inlinenoexcept

Member Function Documentation

◆ getKey()

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

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>
ValueType water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::getValue ( ) const
inline

Returns the current item's value. This should only be called when a call to next() has just returned true.

◆ next()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
bool water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::next ( )
inlinenoexcept

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.

◆ operator!=()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
bool water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::operator!= ( const Iterator & other) const
inlinenoexcept

◆ operator*()

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

◆ operator++()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
Iterator & water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::operator++ ( )
inlinenoexcept

◆ reset()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
void water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::reset ( )
inlinenoexcept

Resets the iterator to its starting position.

◆ resetToEnd()

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
void water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::resetToEnd ( )
inlinenoexcept

Member Data Documentation

◆ entry

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
HashEntry* water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::entry
private

◆ hashMap

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
const HashMap& water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::hashMap
private

◆ index

template<typename KeyType, typename ValueType, class HashFunctionType = DefaultHashFunctions>
int water::HashMap< KeyType, ValueType, HashFunctionType >::Iterator::index
private

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