summaryrefslogtreecommitdiff
path: root/src/hashtable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hashtable.c')
-rw-r--r--src/hashtable.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/hashtable.c b/src/hashtable.c
index b717ffe..d170aa7 100644
--- a/src/hashtable.c
+++ b/src/hashtable.c
@@ -2,21 +2,21 @@
#include "nonport.h"
#include "hashtable.h"
-HashTable *TableNew(u32 p1, s32 p2, HashFunction hf, s32 p4, s32 p5)
+HashTable *TableNew(u32 p1, s32 p2, HashFunction hf, CompareFunction cmp, DtorFunction dtor)
{
- return TableNew2(p1, p2, 4, hf, p4, p5);
+ return TableNew2(p1, p2, 4, hf, cmp, dtor);
}
-HashTable *TableNew2(u32 p1, s32 size, s32 p3, HashFunction hf, s32 p5, s32 p6)
+HashTable *TableNew2(u32 p1, s32 size, s32 p3, HashFunction hf, CompareFunction cmp, DtorFunction dtor)
{
HashTable *table = gsimalloc(sizeof(HashTable));
table->chains = gsimalloc(size * sizeof(DArray *));
for (s32 i = 0; i < size; i++) {
- table->chains[i] = (DArray *)ArrayNew(p1, p3, p6);
+ table->chains[i] = ArrayNew(p1, p3, dtor);
}
table->size = size;
- table->unk8 = p6;
- table->unk10 = p5;
+ table->dtor = dtor;
+ table->compar = cmp;
table->hashFunc = hf;
return table;
}
@@ -47,7 +47,7 @@ void TableEnter(HashTable *table, void *elem)
{
if (table) {
s32 i = table->hashFunc(elem, table->size);
- s32 result = ArraySearch(table->chains[i], elem, table->unk10, 0, 0);
+ s32 result = ArraySearch(table->chains[i], elem, table->compar, 0, 0);
if (result == -1) {
ArrayAppend(table->chains[i], elem);
} else {
@@ -61,7 +61,7 @@ BOOL TableRemove(HashTable *table, void *elem)
if (!table)
return FALSE;
s32 i = table->hashFunc(elem, table->size);
- s32 result = ArraySearch(table->chains[i], elem, table->unk10, 0, 0);
+ s32 result = ArraySearch(table->chains[i], elem, table->compar, 0, 0);
if (result == -1) {
return FALSE;
} else {
@@ -75,7 +75,7 @@ void *TableLookup(HashTable *table, void *elem)
if (!table)
return NULL;
s32 i = table->hashFunc(elem, table->size);
- s32 result = ArraySearch(table->chains[i], elem, table->unk10, 0, 0);
+ s32 result = ArraySearch(table->chains[i], elem, table->compar, 0, 0);
if (result == -1) {
return NULL;
} else {
@@ -83,14 +83,14 @@ void *TableLookup(HashTable *table, void *elem)
}
}
-void TableMapSafe(HashTable *table, s32 p2, s32 p3)
+void TableMapSafe(HashTable *table, MapFunction p2, s32 p3)
{
for (s32 i = 0; i < table->size; i++) {
ArrayMapBackwards(table->chains[i], p2, p3);
}
}
-void *TableMapSafe2(HashTable *table, s32 p2, s32 p3)
+void *TableMapSafe2(HashTable *table, MapFunction p2, s32 p3)
{
s32 i;
void *result;