Skip to content

Commit 3938bd0

Browse files
authored
Merge pull request #68 from yshui/master
hashmap: actually use the hashFunction specified by user
2 parents 92dbd3c + 7a80381 commit 3938bd0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/containers/hashmap.d

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
102102

103103
if (buckets.length == 0)
104104
throw new Exception("'" ~ text(key) ~ "' not found in HashMap");
105-
size_t hash = generateHash(key);
105+
size_t hash = hashFunction(key);
106106
size_t index = hashToIndex(hash);
107107
foreach (r; buckets[index].range)
108108
{
@@ -135,7 +135,7 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
135135

136136
if (_length == 0)
137137
return defaultValue;
138-
size_t hash = generateHash(key);
138+
size_t hash = hashFunction(key);
139139
size_t index = hashToIndex(hash);
140140
foreach (r; buckets[index].range)
141141
{
@@ -168,7 +168,7 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
168168
{
169169
if (_length == 0)
170170
return false;
171-
size_t hash = generateHash(key);
171+
size_t hash = hashFunction(key);
172172
size_t index = hashToIndex(hash);
173173
foreach (ref node; buckets[index].range)
174174
{
@@ -194,7 +194,7 @@ struct HashMap(K, V, Allocator = Mallocator, alias hashFunction = generateHash!K
194194
{
195195
if (buckets.length == 0)
196196
return false;
197-
size_t hash = generateHash(key);
197+
size_t hash = hashFunction(key);
198198
size_t index = hashToIndex(hash);
199199
static if (storeHash)
200200
bool removed = buckets[index].remove(Node(hash, key));
@@ -339,7 +339,7 @@ private:
339339
{
340340
if (buckets.length == 0)
341341
initialize();
342-
size_t hash = generateHash(key);
342+
size_t hash = hashFunction(key);
343343
size_t index = hashToIndex(hash);
344344
foreach (ref item; buckets[index].range)
345345
{
@@ -412,7 +412,7 @@ private:
412412
}
413413
else
414414
{
415-
size_t hash = generateHash(node.key);
415+
size_t hash = hashFunction(node.key);
416416
size_t index = hashToIndex(hash);
417417
buckets[index].put(Node(node.key, node.value));
418418
}
@@ -445,7 +445,7 @@ private:
445445
}
446446
body
447447
{
448-
return hashToIndex(generateHash(key));
448+
return hashToIndex(hashFunction(key));
449449
}
450450

451451
struct Node

0 commit comments

Comments
 (0)