summaryrefslogtreecommitdiff
path: root/src/pathfinder/npf/queue.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-10-02 19:42:42 +0000
committeralberth <alberth@openttd.org>2010-10-02 19:42:42 +0000
commitf185a352693d3d78ced707ef990ccb44a84203e9 (patch)
treea4ceb4a8970fe907836865f6ba8775c879ba8856 /src/pathfinder/npf/queue.cpp
parent15b784471e3fc0aa210399668294481fa7ceb99d (diff)
downloadopenttd-f185a352693d3d78ced707ef990ccb44a84203e9.tar.xz
(svn r20883) -Codechange: Make Hash_Delete a method.
Diffstat (limited to 'src/pathfinder/npf/queue.cpp')
-rw-r--r--src/pathfinder/npf/queue.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp
index b9110d6d9..eac77145b 100644
--- a/src/pathfinder/npf/queue.cpp
+++ b/src/pathfinder/npf/queue.cpp
@@ -427,11 +427,16 @@ static HashNode *Hash_FindNode(const Hash *h, uint key1, uint key2, HashNode** p
return result;
}
-void *Hash_Delete(Hash *h, uint key1, uint key2)
+/**
+ * Deletes the value with the specified key pair from the hash and returns
+ * that value. Returns NULL when the value was not present. The value returned
+ * is _not_ free()'d!
+ */
+void *Hash::DeleteValue(uint key1, uint key2)
{
void *result;
HashNode *prev; // Used as output var for below function call
- HashNode *node = Hash_FindNode(h, key1, key2, &prev);
+ HashNode *node = Hash_FindNode(this, key1, key2, &prev);
if (node == NULL) {
/* not found */
@@ -452,8 +457,8 @@ void *Hash_Delete(Hash *h, uint key1, uint key2)
} else {
/* This was the last in this bucket
* Mark it as empty */
- uint hash = h->hash(key1, key2);
- h->buckets_in_use[hash] = false;
+ uint hash = this->hash(key1, key2);
+ this->buckets_in_use[hash] = false;
}
} else {
/* It is in another node
@@ -466,7 +471,7 @@ void *Hash_Delete(Hash *h, uint key1, uint key2)
free(node);
#endif
}
- if (result != NULL) h->size--;
+ if (result != NULL) this->size--;
return result;
}