3 * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net>
5 * Free Software License:
7 * All rights are reserved by the author, with the following exceptions:
8 * Permission is granted to freely reproduce and distribute this software,
9 * possibly in exchange for a fee, provided that this copyright notice appears
10 * intact. Permission is also granted to adapt this software to produce
11 * derivative works, as long as the modified versions carry this copyright
12 * notice and additional notices stating that the work has been modified.
13 * This source code may be translated into executable form and incorporated
14 * into proprietary software; there is no requirement for such software to
15 * contain a copyright notice related to this source.
17 * $Id: hash.h,v 1.2 2009-10-02 09:32:40 franklahm Exp $
25 #include <atalk/hash.h>
27 extern hash_t *hash_create(hashcount_t, hash_comp_t, hash_fun_t);
28 extern void hash_set_allocator(hash_t *, hnode_alloc_t, hnode_free_t, void *);
29 extern void hash_destroy(hash_t *);
30 extern void hash_free_nodes(hash_t *);
31 extern void hash_free(hash_t *);
32 extern hash_t *hash_init(hash_t *, hashcount_t, hash_comp_t,
33 hash_fun_t, hnode_t **, hashcount_t);
34 extern void hash_insert(hash_t *, hnode_t *, const void *);
35 extern hnode_t *hash_lookup(hash_t *, const void *);
36 extern hnode_t *hash_delete(hash_t *, hnode_t *);
37 extern int hash_alloc_insert(hash_t *, const void *, void *);
38 extern void hash_delete_free(hash_t *, hnode_t *);
40 extern void hnode_put(hnode_t *, void *);
41 extern void *hnode_get(hnode_t *);
42 extern const void *hnode_getkey(hnode_t *);
43 extern hashcount_t hash_count(hash_t *);
44 extern hashcount_t hash_size(hash_t *);
46 extern int hash_isfull(hash_t *);
47 extern int hash_isempty(hash_t *);
49 extern void hash_scan_begin(hscan_t *, hash_t *);
50 extern hnode_t *hash_scan_next(hscan_t *);
51 extern hnode_t *hash_scan_delete(hash_t *, hnode_t *);
52 extern void hash_scan_delfree(hash_t *, hnode_t *);
54 extern int hash_verify(hash_t *);
56 extern hnode_t *hnode_create(void *);
57 extern hnode_t *hnode_init(hnode_t *, void *);
58 extern void hnode_destroy(hnode_t *);
60 #if defined(HASH_IMPLEMENTATION) || !defined(KAZLIB_OPAQUE_DEBUG)
61 #ifdef KAZLIB_SIDEEFFECT_DEBUG
62 #define hash_isfull(H) (SFX_CHECK(H)->hash_nodecount == (H)->hash_maxcount)
64 #define hash_isfull(H) ((H)->hash_nodecount == (H)->hash_maxcount)
66 #define hash_isempty(H) ((H)->hash_nodecount == 0)
67 #define hash_count(H) ((H)->hash_nodecount)
68 #define hash_size(H) ((H)->hash_nchains)
69 #define hnode_get(N) ((N)->hash_data)
70 #define hnode_getkey(N) ((N)->hash_key)
71 #define hnode_put(N, V) ((N)->hash_data = (V))