summaryrefslogtreecommitdiffstats
path: root/libopkg/hash_table.h
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-14 23:25:08 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-14 23:25:08 (EST)
commit4b0b7ca249bfa4ecc099c2ca56527eb91776f198 (patch)
treedb5d2602d75a69cc9e1f7f30cbac584f0ab45c45 /libopkg/hash_table.h
parent868cbd739052719d5e0580a0fda6101dada1ce1e (diff)
opkg: re-arrange source code into sub-directories
git-svn-id: http://opkg.googlecode.com/svn/trunk@33 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/hash_table.h')
-rw-r--r--libopkg/hash_table.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/libopkg/hash_table.h b/libopkg/hash_table.h
new file mode 100644
index 0000000..388a966
--- /dev/null
+++ b/libopkg/hash_table.h
@@ -0,0 +1,44 @@
+/* hash.h - hash tables for opkg
+
+ Steven M. Ayer, Jamey Hicks
+
+ Copyright (C) 2002 Compaq Computer Corporation
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+*/
+
+#ifndef _HASH_TABLE_H_
+#define _HASH_TABLE_H_
+
+typedef struct hash_entry hash_entry_t;
+typedef struct hash_table hash_table_t;
+
+struct hash_entry {
+ const char * key;
+ void * data;
+ struct hash_entry * next;
+};
+
+struct hash_table {
+ const char *name;
+ hash_entry_t * entries;
+ int n_entries; /* number of buckets */
+ int n_elements;
+ const char * (*hash_entry_key)(void * data);
+};
+
+int hash_table_init(const char *name, hash_table_t *hash, int len);
+void hash_table_deinit(hash_table_t *hash);
+void *hash_table_get(hash_table_t *hash, const char *key);
+int hash_table_insert(hash_table_t *hash, const char *key, void *value);
+void hash_table_foreach(hash_table_t *hash, void (*f)(const char *key, void *entry, void *data), void *data);
+
+#endif /* _HASH_TABLE_H_ */