summaryrefslogtreecommitdiffstats
path: root/zix/hash.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-09-28 17:41:06 +0000
committerDavid Robillard <d@drobilla.net>2011-09-28 17:41:06 +0000
commit0e3ef580b5d265ee59d50d35053e989b8c4277c2 (patch)
treec3989bba215b866ae8c56a276cd4d577b43f26be /zix/hash.h
parent95fd16cd2d7d2394418210199f1275caab8965d0 (diff)
downloadzix-0e3ef580b5d265ee59d50d35053e989b8c4277c2.tar.gz
zix-0e3ef580b5d265ee59d50d35053e989b8c4277c2.tar.bz2
zix-0e3ef580b5d265ee59d50d35053e989b8c4277c2.zip
Add ZixHash
git-svn-id: http://svn.drobilla.net/zix/trunk@39 df6676b4-ccc9-40e5-b5d6-7c4628a128e3
Diffstat (limited to 'zix/hash.h')
-rw-r--r--zix/hash.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/zix/hash.h b/zix/hash.h
new file mode 100644
index 0000000..44521f1
--- /dev/null
+++ b/zix/hash.h
@@ -0,0 +1,75 @@
+/*
+ Copyright 2011 David Robillard <http://drobilla.net>
+
+ Permission to use, copy, modify, and/or distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#ifndef ZIX_HASH_H
+#define ZIX_HASH_H
+
+#include "zix/common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ZixHashImpl ZixHash;
+
+/**
+ Function for computing the hash of an element.
+*/
+typedef unsigned (*ZixHashFunc)(const void* key);
+
+ZIX_API
+ZixHash*
+zix_hash_new(ZixHashFunc hash_func,
+ ZixEqualFunc key_equal_func);
+
+ZIX_API
+void
+zix_hash_free(ZixHash* hash);
+
+ZIX_API
+unsigned
+zix_string_hash(const void* key);
+
+ZIX_API
+bool
+zix_string_equal(const void* a, const void* b);
+
+ZIX_API
+ZixStatus
+zix_hash_insert(ZixHash* hash,
+ const void* key,
+ void* data);
+
+ZIX_API
+ZixStatus
+zix_hash_remove(ZixHash* hash, const void* key);
+
+ZIX_API
+void*
+zix_hash_find(const ZixHash* hash,
+ const void* key);
+
+ZIX_API
+void
+zix_hash_foreach(const ZixHash* hash,
+ void (*f)(const void* key, void* value, void* user_data),
+ void* user_data);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* ZIX_HASH_H */