summaryrefslogtreecommitdiff
path: root/hash.h
diff options
context:
space:
mode:
authorGraydon, Tracy <tracy.graydon@intel.com>2013-01-31 17:53:28 -0800
committerGraydon, Tracy <tracy.graydon@intel.com>2013-01-31 17:53:28 -0800
commit2f9aed644fc28f5bece6ab1711a9fca7362aeceb (patch)
treeccd6c62f1adf3255ed0b2095feab505e4611374e /hash.h
downloadiftop-2f9aed644fc28f5bece6ab1711a9fca7362aeceb.tar.gz
iftop-2f9aed644fc28f5bece6ab1711a9fca7362aeceb.tar.bz2
iftop-2f9aed644fc28f5bece6ab1711a9fca7362aeceb.zip
Diffstat (limited to 'hash.h')
-rw-r--r--hash.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/hash.h b/hash.h
new file mode 100644
index 0000000..9cb3460
--- /dev/null
+++ b/hash.h
@@ -0,0 +1,40 @@
+/*
+ * addr_hash.h:
+ *
+ */
+
+#ifndef __HASH_H_ /* include guard */
+#define __HASH_H_
+
+/* implementation independent declarations */
+typedef enum {
+ HASH_STATUS_OK,
+ HASH_STATUS_MEM_EXHAUSTED,
+ HASH_STATUS_KEY_NOT_FOUND
+} hash_status_enum;
+
+typedef struct node_tag {
+ struct node_tag *next; /* next node */
+ void* key; /* key */
+ void* rec; /* user data */
+} hash_node_type;
+
+typedef struct {
+ int (*compare) (void*, void*);
+ int (*hash) (void*);
+ void* (*copy_key) (void*);
+ void (*delete_key) (void*);
+ hash_node_type** table;
+ int size;
+} hash_type;
+
+
+hash_status_enum hash_initialise(hash_type*);
+hash_status_enum hash_destroy(hash_type*);
+hash_status_enum hash_insert(hash_type*, void* key, void *rec);
+hash_status_enum hash_delete(hash_type* hash_table, void* key);
+hash_status_enum hash_find(hash_type* hash_table, void* key, void** rec);
+hash_status_enum hash_next_item(hash_type* hash_table, hash_node_type** ppnode);
+void hash_delete_all(hash_type* hash_table);
+
+#endif /* __HASH_H_ */