Olaf
Overly Lightweight Acoustic Fingerprinting
Loading...
Searching...
No Matches
hash-table.h
Go to the documentation of this file.
1/*
2
3Copyright (c) 2005-2008, Simon Howard
4
5Permission to use, copy, modify, and/or distribute this software
6for any purpose with or without fee is hereby granted, provided
7that the above copyright notice and this permission notice appear
8in all copies.
9
10THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
17CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18
19 */
20
44
45#ifndef ALGORITHM_HASH_TABLE_H
46#define ALGORITHM_HASH_TABLE_H
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
55
56typedef struct _HashTable HashTable;
57
61
63
67
69
73
74typedef void *HashTableKey;
75
79
80typedef void *HashTableValue;
81
86
87typedef struct _HashTablePair{
88 HashTableKey key;
89 HashTableValue value;
91
95
97 HashTable *hash_table;
98 HashTableEntry *next_entry;
99 unsigned int next_chain;
100};
101
105
106#define HASH_TABLE_NULL ((void *) 0)
107
115
116typedef unsigned int (*HashTableHashFunc)(HashTableKey value);
117
124
125typedef int (*HashTableEqualFunc)(HashTableKey value1, HashTableKey value2);
126
131
132typedef void (*HashTableKeyFreeFunc)(HashTableKey value);
133
138
140
152
154 HashTableEqualFunc equal_func);
155
161
162void hash_table_free(HashTable *hash_table);
163
172
174 HashTableKeyFreeFunc key_free_func,
175 HashTableValueFreeFunc value_free_func);
176
188
189int hash_table_insert(HashTable *hash_table,
190 HashTableKey key,
191 HashTableValue value);
192
201
203 HashTableKey key);
204
213
214int hash_table_remove(HashTable *hash_table, HashTableKey key);
215
222
223unsigned int hash_table_num_entries(HashTable *hash_table);
224
232
233void hash_table_iterate(HashTable *hash_table, HashTableIterator *iter);
234
244
246
261
263
264#ifdef __cplusplus
265}
266#endif
267
268#endif /* #ifndef ALGORITHM_HASH_TABLE_H */
269
HashTableValue hash_table_lookup(HashTable *hash_table, HashTableKey key)
Definition hash-table.c:344
int hash_table_insert(HashTable *hash_table, HashTableKey key, HashTableValue value)
Definition hash-table.c:251
HashTablePair hash_table_iter_next(HashTableIterator *iterator)
Definition hash-table.c:464
unsigned int(* HashTableHashFunc)(HashTableKey value)
Definition hash-table.h:116
void(* HashTableKeyFreeFunc)(HashTableKey value)
Definition hash-table.h:132
void * HashTableValue
Definition hash-table.h:80
int hash_table_remove(HashTable *hash_table, HashTableKey key)
Definition hash-table.c:377
int hash_table_iter_has_more(HashTableIterator *iterator)
Definition hash-table.c:459
int(* HashTableEqualFunc)(HashTableKey value1, HashTableKey value2)
Definition hash-table.h:125
struct _HashTableEntry HashTableEntry
Definition hash-table.h:68
void hash_table_iterate(HashTable *hash_table, HashTableIterator *iter)
Definition hash-table.c:437
HashTable * hash_table_new(HashTableHashFunc hash_func, HashTableEqualFunc equal_func)
Definition hash-table.c:119
struct _HashTablePair HashTablePair
struct _HashTableIterator HashTableIterator
Definition hash-table.h:62
unsigned int hash_table_num_entries(HashTable *hash_table)
Definition hash-table.c:432
struct _HashTable HashTable
Definition hash-table.h:56
void * HashTableKey
Definition hash-table.h:74
void(* HashTableValueFreeFunc)(HashTableValue value)
Definition hash-table.h:139
void hash_table_free(HashTable *hash_table)
Definition hash-table.c:150
void hash_table_register_free_functions(HashTable *hash_table, HashTableKeyFreeFunc key_free_func, HashTableValueFreeFunc value_free_func)
Definition hash-table.c:176
Definition hash-table.c:34
Definition hash-table.c:39
Definition hash-table.h:96
Definition hash-table.h:87