aboutsummaryrefslogtreecommitdiff
path: root/hash.inc.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-02-05 15:38:03 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-05 18:16:19 +0100
commit447e42b4fbf5567b3cf96ddee0186f76f0c7ebe9 (patch)
tree349566b092f4d6f566cad3411f4e926534c5b304 /hash.inc.h
parentAdd single file mode. (diff)
downloadcalp-447e42b4fbf5567b3cf96ddee0186f76f0c7ebe9.tar.gz
calp-447e42b4fbf5567b3cf96ddee0186f76f0c7ebe9.tar.xz
Improve templating macros.
Diffstat (limited to 'hash.inc.h')
-rw-r--r--hash.inc.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/hash.inc.h b/hash.inc.h
index 6ded0628..0aee8ef4 100644
--- a/hash.inc.h
+++ b/hash.inc.h
@@ -4,7 +4,7 @@
#include "err.h"
-int HASH_PUT(TYPE) ( TABLE(TYPE)* table, TYPE* value) {
+int PUT(HASHT(TYPE)) ( HASHT(TYPE)* table, TYPE* value) {
// TODO genicify the hash function
unsigned long h = hash(value->key.mem) % table->size;
TYPE* mem = table->values[h];
@@ -17,7 +17,7 @@ int HASH_PUT(TYPE) ( TABLE(TYPE)* table, TYPE* value) {
return 0;
}
-INIT_F(HASH(TYPE), int init_size ) {
+INIT_F(HASHT(TYPE), int init_size ) {
/*
* TODO parts of table might not get properly initialized to 0
*/
@@ -27,7 +27,7 @@ INIT_F(HASH(TYPE), int init_size ) {
return 0;
}
-TYPE* HASH_GET(TYPE) ( TABLE(TYPE)* table, char* key ) {
+TYPE* GET(HASHT(TYPE)) ( HASHT(TYPE)* table, char* key ) {
unsigned long h = hash(key) % table->size;
TYPE* mem = table->values[h];
if (mem == NULL) {
@@ -43,7 +43,7 @@ TYPE* HASH_GET(TYPE) ( TABLE(TYPE)* table, char* key ) {
}
}
-FREE(HASH(TYPE)) {
+FREE(HASHT(TYPE)) {
/*
* TODO an early return is possible by checking if all items have
* been found. table->item_count