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
45#ifndef ALGORITHM_HASH_TABLE_H
46#define ALGORITHM_HASH_TABLE_H
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
56typedef struct _HashTable HashTable;
57
63
69
74typedef void *HashTableKey;
75
80typedef void *HashTableValue;
81
87typedef struct _HashTablePair{
88 HashTableKey key;
89 HashTableValue value;
91
97 HashTable *hash_table;
98 HashTableEntry *next_entry;
99 unsigned int next_chain;
100};
101
106#define HASH_TABLE_NULL ((void *) 0)
107
116typedef unsigned int (*HashTableHashFunc)(HashTableKey value);
117
125typedef int (*HashTableEqualFunc)(HashTableKey value1, HashTableKey value2);
126
132typedef void (*HashTableKeyFreeFunc)(HashTableKey value);
133
140
154 HashTableEqualFunc equal_func);
155
162void hash_table_free(HashTable *hash_table);
163
174 HashTableKeyFreeFunc key_free_func,
175 HashTableValueFreeFunc value_free_func);
176
189int hash_table_insert(HashTable *hash_table,
190 HashTableKey key,
191 HashTableValue value);
192
203 HashTableKey key);
204
214int hash_table_remove(HashTable *hash_table, HashTableKey key);
215
223unsigned int hash_table_num_entries(HashTable *hash_table);
224
233void hash_table_iterate(HashTable *hash_table, HashTableIterator *iter);
234
246
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
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
unsigned int hash_table_num_entries(HashTable *hash_table)
Definition: hash-table.c:432
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