aboutsummaryrefslogtreecommitdiffstats
path: root/include/strmap.h
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-01 13:31:38 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-01 13:31:38 -0400
commit6338ac827b15787a0d83136eac9d681588f07f9a (patch)
treef808100cd52e54c632b31b8a42f3bdb703f3d31a /include/strmap.h
downloadlibmap-6338ac827b15787a0d83136eac9d681588f07f9a.tar.gz
Initial commit
Diffstat (limited to 'include/strmap.h')
-rwxr-xr-xinclude/strmap.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/strmap.h b/include/strmap.h
new file mode 100755
index 0000000..634da60
--- /dev/null
+++ b/include/strmap.h
@@ -0,0 +1,38 @@
+/*
+ * strmap.h
+ *
+ * A close-addressing based string -> string hash map
+ * for CISC 301: Operating Systems
+ */
+
+#ifndef H_STRMAP
+#define H_STRMAP
+
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct strmap strmap;
+typedef size_t (*hash_func) (const char *, size_t);
+
+typedef enum {
+ STRMAP_OK,
+ STRMAP_ERR,
+ STRMAP_NOTFOUND
+} strmap_status;
+
+/*
+ * Inserts a new string into a strmap, returning
+ */
+strmap_status strmap_put(strmap*, const char*, const char*);
+
+strmap_status strmap_get(const strmap*, const char*, const char**);
+
+strmap_status strmap_delete(strmap*, const char*);
+
+size_t strmap_size(const strmap*);
+
+strmap *strmap_create(hash_func);
+void strmap_destroy(strmap *);
+
+
+#endif