aboutsummaryrefslogtreecommitdiff
path: root/hash.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-01-19 19:06:09 +0100
committerHugo Hörnquist <hugo@hornquist.se>2019-01-19 19:06:14 +0100
commitc42c2834d8c7b5d81465b9d9d127d8384151b9cb (patch)
tree53b1a8eb0368d5f91525604eea2c3173083c1955 /hash.h
parentCan now parse entire directory in one go. (diff)
downloadcalp-c42c2834d8c7b5d81465b9d9d127d8384151b9cb.tar.gz
calp-c42c2834d8c7b5d81465b9d9d127d8384151b9cb.tar.xz
[BROKEN] Work on adding hash tables.
Diffstat (limited to 'hash.h')
-rw-r--r--hash.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/hash.h b/hash.h
new file mode 100644
index 00000000..2a095cfd
--- /dev/null
+++ b/hash.h
@@ -0,0 +1,30 @@
+#ifndef HASH_H
+#define HASH_H
+
+#include <string.h>
+
+#include "macro.h"
+
+unsigned long hash(char*);
+
+#define TABLE(T) TP(table_, T)
+#define HASH_PUT(T) TP(hash_put_, T)
+#define HASH_GET(T) TP(hash_get_, T)
+#define HASH_INIT(T) TP(hash_init_, T)
+
+#endif /* HASH_H */
+#ifdef TYPE
+
+typedef struct {
+ int size;
+ int item_count;
+ TYPE* values;
+} TABLE(TYPE);
+
+int HASH_PUT(TYPE) ( TABLE(TYPE)* table, TYPE* value );
+
+int HASH_INIT(TYPE) ( TABLE(TYPE)* table, int init_size );
+
+TYPE* HASH_GET(TYPE) ( TABLE(TYPE)* table, char* key );
+
+#endif /* HASH_H */