libdict
Data Structure C Library
Loading...
Searching...
No Matches
hashtable.h
Go to the documentation of this file.
1/*
2 * libdict -- hash-value sorted, chained hash-table interface.
3 *
4 * Copyright (c) 2001-2014, Farooq Mela
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef LIBDICT_HASHTABLE_H__
29#define LIBDICT_HASHTABLE_H__
30
31#include "dict.h"
32
34
35typedef struct hashtable hashtable;
36
40
42 hashtable_insert(hashtable* table, void* key);
43void** hashtable_search(hashtable* table, const void* key);
45 hashtable_remove(hashtable* table, const void* key);
47size_t hashtable_traverse(hashtable* table, dict_visit_func visit, void* user_data);
48size_t hashtable_count(const hashtable* table);
49size_t hashtable_size(const hashtable* table);
52bool hashtable_resize(hashtable* table, unsigned size);
53
55
59
60bool hashtable_itor_valid(const hashtable_itor* itor);
64bool hashtable_itor_nextn(hashtable_itor* itor, size_t count);
65bool hashtable_itor_prevn(hashtable_itor* itor, size_t count);
68bool hashtable_itor_search(hashtable_itor* itor, const void* key);
69const void* hashtable_itor_key(const hashtable_itor* itor);
72
74
75#endif /* !LIBDICT_HASHTABLE_H__ */
#define BEGIN_DECL
Definition dict.h:35
int(* dict_compare_func)(const void *, const void *)
Definition dict.h:54
void(* dict_delete_func)(void *, void *)
Definition dict.h:57
unsigned(* dict_hash_func)(const void *)
Definition dict.h:61
#define END_DECL
Definition dict.h:36
bool(* dict_visit_func)(const void *, void *, void *)
Definition dict.h:59
size_t hashtable_free(hashtable *table, dict_delete_func delete_func)
Definition hashtable.c:152
bool hashtable_resize(hashtable *table, unsigned size)
Definition hashtable.c:305
bool hashtable_itor_search(hashtable_itor *itor, const void *key)
Definition hashtable.c:511
dict_remove_result hashtable_remove(hashtable *table, const void *key)
Definition hashtable.c:233
dict_itor * hashtable_dict_itor_new(hashtable *table)
Definition hashtable.c:378
hashtable_itor * hashtable_itor_new(hashtable *table)
Definition hashtable.c:366
bool hashtable_verify(const hashtable *table)
Definition hashtable.c:345
bool hashtable_itor_last(hashtable_itor *itor)
Definition hashtable.c:493
bool hashtable_itor_next(hashtable_itor *itor)
Definition hashtable.c:411
bool hashtable_itor_first(hashtable_itor *itor)
Definition hashtable.c:478
size_t hashtable_count(const hashtable *table)
Definition hashtable.c:283
bool hashtable_itor_prevn(hashtable_itor *itor, size_t count)
Definition hashtable.c:468
dict_insert_result hashtable_insert(hashtable *table, void *key)
Definition hashtable.c:163
void ** hashtable_itor_datum(hashtable_itor *itor)
Definition hashtable.c:536
bool hashtable_itor_remove(hashtable_itor *itor)
Definition hashtable.c:542
void hashtable_itor_free(hashtable_itor *itor)
Definition hashtable.c:392
bool hashtable_itor_nextn(hashtable_itor *itor, size_t count)
Definition hashtable.c:458
size_t hashtable_clear(hashtable *table, dict_delete_func delete_func)
Definition hashtable.c:251
bool hashtable_itor_prev(hashtable_itor *itor)
Definition hashtable.c:433
void hashtable_itor_invalidate(hashtable_itor *itor)
Definition hashtable.c:404
size_t hashtable_traverse(hashtable *table, dict_visit_func visit, void *user_data)
Definition hashtable.c:270
dict * hashtable_dict_new(dict_compare_func cmp_func, dict_hash_func hash_func, unsigned size)
Definition hashtable.c:134
bool hashtable_itor_valid(const hashtable_itor *itor)
Definition hashtable.c:398
void ** hashtable_search(hashtable *table, const void *key)
Definition hashtable.c:204
size_t hashtable_size(const hashtable *table)
Definition hashtable.c:289
size_t hashtable_slots_used(const hashtable *table)
Definition hashtable.c:295
const void * hashtable_itor_key(const hashtable_itor *itor)
Definition hashtable.c:530
hashtable * hashtable_new(dict_compare_func cmp_func, dict_hash_func hash_func, unsigned size)
Definition hashtable.c:111
Definition dict.h:151
hashtable * table
Definition hashtable.c:66
unsigned size
Definition hashtable.c:62
dict_compare_func cmp_func
Definition hashtable.c:59
hash_node ** table
Definition hashtable.c:58
dict_hash_func hash_func
Definition hashtable.c:60