99template <
typename KeyType,
101 class HashFunctionType = DefaultHashFunctions,
102 class TypeOfCriticalSectionToUse = DummyCriticalSection>
122 HashFunctionType hashFunction = HashFunctionType())
125 hashSlots.insertMultiple (0,
nullptr, numberOfSlots);
149 const std::unique_ptr<HashEntry> deleter (
h);
190 auto* firstEntry =
hashSlots.getUnchecked (hashIndex);
192 if (
auto* entry =
getEntry (firstEntry, keyToLookFor))
195 auto* entry =
new HashEntry (keyToLookFor, ValueType(), firstEntry);
220 for (
auto* entry =
hashSlots.getUnchecked(
i); entry !=
nullptr; entry = entry->nextEntry)
221 if (entry->value == valueToLookFor)
239 auto* entry =
hashSlots.getUnchecked (hashIndex);
242 while (entry !=
nullptr)
244 if (entry->key == keyToRemove)
246 const std::unique_ptr<HashEntry> deleter (entry);
248 entry = entry->nextEntry;
250 if (previous !=
nullptr)
275 while (entry !=
nullptr)
277 if (entry->value == valueToRemove)
279 const std::unique_ptr<HashEntry> deleter (entry);
281 entry = entry->nextEntry;
283 if (previous !=
nullptr)
314 for (
auto* entry =
hashSlots.getUnchecked(
i); entry !=
nullptr; entry = nextEntry)
321 newSlots.
set (hashIndex, entry);
339 template <
class OtherHashMapType>
340 void swapWith (OtherHashMapType& otherHashMap)
noexcept
343 const typename OtherHashMapType::ScopedLockType lock2 (otherHashMap.getLock());
345 hashSlots.swapWith (otherHashMap.hashSlots);
415 if (
entry !=
nullptr)
418 while (
entry ==
nullptr)
434 return entry !=
nullptr ?
entry->key : KeyType();
442 return entry !=
nullptr ?
entry->value : ValueType();
454 bool operator!= (
const Iterator& other)
const noexcept {
return entry != other.entry ||
index != other.index; }
483 TypeOfCriticalSectionToUse
lock;
494 for (
auto* entry = firstEntry; entry !=
nullptr; entry = entry->nextEntry)
495 if (entry->key == keyToLookFor)
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Array.h:56
ElementType getUnchecked(int index) const
Definition juce_Array.h:252
void set(int indexToChange, ParameterType newValue)
Definition juce_Array.h:542
void insertMultiple(int indexToInsertAt, ParameterType newElement, int numberOfTimesToInsertIt)
Definition juce_Array.h:480
Definition juce_HashMap.h:362
HashEntry(KeyTypeParameter k, ValueTypeParameter val, HashEntry *const next)
Definition juce_HashMap.h:364
const KeyType key
Definition juce_HashMap.h:368
HashEntry * nextEntry
Definition juce_HashMap.h:370
ValueType value
Definition juce_HashMap.h:369
Definition juce_HashMap.h:104
~HashMap()
Definition juce_HashMap.h:129
int getNumSlots() const noexcept
Definition juce_HashMap.h:332
bool containsValue(ValueTypeParameter valueToLookFor) const
Definition juce_HashMap.h:215
const TypeOfCriticalSectionToUse & getLock() const noexcept
Definition juce_HashMap.h:354
static HashEntry * getEntry(HashEntry *firstEntry, KeyType keyToLookFor) noexcept
Definition juce_HashMap.h:492
Iterator begin() const noexcept
Definition juce_HashMap.h:470
Array< HashEntry * > hashSlots
Definition juce_HashMap.h:481
void swapWith(OtherHashMapType &otherHashMap) noexcept
Definition juce_HashMap.h:340
void remove(KeyTypeParameter keyToRemove)
Definition juce_HashMap.h:235
void set(KeyTypeParameter newKey, ValueTypeParameter newValue)
Definition juce_HashMap.h:232
void remapTable(int newNumberOfSlots)
Definition juce_HashMap.h:303
@ defaultHashTableSize
Definition juce_HashMap.h:477
bool contains(KeyTypeParameter keyToLookFor) const
Definition juce_HashMap.h:207
HashEntry * getSlot(KeyType key) const noexcept
Definition juce_HashMap.h:501
void removeValue(ValueTypeParameter valueToRemove)
Definition juce_HashMap.h:266
void clear()
Definition juce_HashMap.h:139
typename TypeHelpers::ParameterType< KeyType >::type KeyTypeParameter
Definition juce_HashMap.h:106
typename TypeOfCriticalSectionToUse::ScopedLockType ScopedLockType
Definition juce_HashMap.h:357
int generateHashFor(KeyTypeParameter key, int numSlots) const
Definition juce_HashMap.h:485
Iterator end() const noexcept
Definition juce_HashMap.h:473
typename TypeHelpers::ParameterType< ValueType >::type ValueTypeParameter
Definition juce_HashMap.h:107
TypeOfCriticalSectionToUse lock
Definition juce_HashMap.h:483
ValueType & getReference(KeyTypeParameter keyToLookFor)
Definition juce_HashMap.h:185
int size() const noexcept
Definition juce_HashMap.h:161
int totalNumItems
Definition juce_HashMap.h:482
HashFunctionType hashFunctionToUse
Definition juce_HashMap.h:480
HashMap(int numberOfSlots=defaultHashTableSize, HashFunctionType hashFunction=HashFunctionType())
Definition juce_HashMap.h:121
Definition juce_String.h:53
Definition juce_Uuid.h:39
Definition juce_Variant.h:42
register unsigned k
Definition inflate.c:946
register unsigned i
Definition inflate.c:1575
int val
Definition jpeglib.h:956
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition juce_LeakedObjectDetector.h:138
Definition carla_juce.cpp:31
unsigned long long uint64
Definition juce_MathsFunctions.h:56
unsigned int uint32
Definition juce_MathsFunctions.h:45
long long int64
Definition juce_MathsFunctions.h:54
signed int int32
Definition juce_MathsFunctions.h:43
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Definition juce_MathsFunctions.h:279
unsigned int pointer_sized_uint
Definition juce_MathsFunctions.h:82
Definition juce_HashMap.h:35
static int generateHash(const void *key, int upperLimit) noexcept
Definition juce_HashMap.h:49
static int generateHash(int32 key, int upperLimit) noexcept
Definition juce_HashMap.h:39
static int generateHash(const String &key, int upperLimit) noexcept
Definition juce_HashMap.h:45
static int generateHash(int64 key, int upperLimit) noexcept
Definition juce_HashMap.h:43
static int generateHash(uint64 key, int upperLimit) noexcept
Definition juce_HashMap.h:41
static int generateHash(const Uuid &key, int upperLimit) noexcept
Definition juce_HashMap.h:51
static int generateHash(const var &key, int upperLimit) noexcept
Definition juce_HashMap.h:47
static int generateHash(uint32 key, int upperLimit) noexcept
Definition juce_HashMap.h:37
Definition juce_HashMap.h:400
ValueType getValue() const
Definition juce_HashMap.h:440
Iterator(const HashMap &hashMapToIterate) noexcept
Definition juce_HashMap.h:401
int index
Definition juce_HashMap.h:461
const HashMap & hashMap
Definition juce_HashMap.h:459
void resetToEnd() noexcept
Definition juce_HashMap.h:455
bool next() noexcept
Definition juce_HashMap.h:413
ValueType operator*() const
Definition juce_HashMap.h:453
KeyType getKey() const
Definition juce_HashMap.h:432
HashEntry * entry
Definition juce_HashMap.h:460
Iterator(const Iterator &other) noexcept
Definition juce_HashMap.h:405
Iterator & operator++() noexcept
Definition juce_HashMap.h:452
void reset() noexcept
Definition juce_HashMap.h:446
const Type & type
Definition juce_MathsFunctions.h:632
ZCONST char * key
Definition crypt.c:587
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
#define const
Definition zconf.h:137