1/* 2 * Hash Table Data Type 3 * Copyright (C) 1997 Kaz Kylheku <kaz@ashi.footprints.net> 4 * 5 * Free Software License: 6 * 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. 16 * 17 * $Id: hash.h,v 1.2 2009-10-02 09:32:40 franklahm Exp $ 18 * $Name: $ 19 */ 20 21#ifndef HASH_H 22#define HASH_H 23 24#include <limits.h> 25#include <atalk/hash.h> 26 27extern hash_t *hash_create(hashcount_t, hash_comp_t, hash_fun_t); 28extern void hash_set_allocator(hash_t *, hnode_alloc_t, hnode_free_t, void *); 29extern void hash_destroy(hash_t *); 30extern void hash_free_nodes(hash_t *); 31extern void hash_free(hash_t *); 32extern hash_t *hash_init(hash_t *, hashcount_t, hash_comp_t, 33 hash_fun_t, hnode_t **, hashcount_t); 34extern void hash_insert(hash_t *, hnode_t *, const void *); 35extern hnode_t *hash_lookup(hash_t *, const void *); 36extern hnode_t *hash_delete(hash_t *, hnode_t *); 37extern int hash_alloc_insert(hash_t *, const void *, void *); 38extern void hash_delete_free(hash_t *, hnode_t *); 39 40extern void hnode_put(hnode_t *, void *); 41extern void *hnode_get(hnode_t *); 42extern const void *hnode_getkey(hnode_t *); 43extern hashcount_t hash_count(hash_t *); 44extern hashcount_t hash_size(hash_t *); 45 46extern int hash_isfull(hash_t *); 47extern int hash_isempty(hash_t *); 48 49extern void hash_scan_begin(hscan_t *, hash_t *); 50extern hnode_t *hash_scan_next(hscan_t *); 51extern hnode_t *hash_scan_delete(hash_t *, hnode_t *); 52extern void hash_scan_delfree(hash_t *, hnode_t *); 53 54extern int hash_verify(hash_t *); 55 56extern hnode_t *hnode_create(void *); 57extern hnode_t *hnode_init(hnode_t *, void *); 58extern void hnode_destroy(hnode_t *); 59 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) 63#else 64#define hash_isfull(H) ((H)->hash_nodecount == (H)->hash_maxcount) 65#endif 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)) 72#endif 73 74#endif 75