summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorleo <leo@azuminha.com>2024-04-03 15:16:39 -0300
committerleo <leo@azuminha.com>2024-04-03 15:16:39 -0300
commit6a564da0f9c510c0222b05ba5da18c6ef73e8030 (patch)
treeba76677e1ce186cc31b31d3a04749b2c9889f625 /include
map implementado
Diffstat (limited to 'include')
-rw-r--r--include/map.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/map.h b/include/map.h
new file mode 100644
index 0000000..1dea3e7
--- /dev/null
+++ b/include/map.h
@@ -0,0 +1,31 @@
+#ifndef _MYMAP_H
+#define _MYMAP_H
+
+#include <string.h>
+#include <stdint.h>
+
+#define A
+
+typedef struct Node{
+ char *key;
+ char *value;
+ struct Node *next;
+}node;
+
+typedef struct Map{
+ uint32_t size;
+ node **head;
+}string_map;
+
+string_map init_map(uint32_t size);
+/*
+ * 64-bit FNV-1 hash
+ * https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
+ */
+#define FNV_offset_basis 14695981039346656037UL
+#define FNV_prime 1099511628211UL
+uint32_t hash_function(char *key, uint32_t size);
+void insert_map(char *key, char *value, string_map map);
+node *create_node(char *key, char *value);
+char *get_value(char *key, string_map map);
+#endif