Reordered files
[svmtool++.git] / include / hash.h
blob85f26ae8b3babc7f14df63a41bfaee1ed8d86206
1 /*
2 * Copyright (C) 2004 Jesus Gimenez, Lluis Marquez and Senen Moya
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef SVMT_HASH_H
21 #include <stdint.h>
23 #ifdef __cplusplus
24 extern "C"
26 #endif
28 typedef struct hash_t
30 struct hash_node_t **bucket; /* array of hash nodes */
31 int size; /* size of the array */
32 int entries; /* number of entries in table */
33 int downshift; /* shift cound, used in hash function */
34 int mask; /* used to select bits for hashing */
35 } hash_t;
37 typedef struct hash_node_t
39 uintptr_t data; /* data in hash node */
40 const char * key; /* key for hash lookup */
41 struct hash_node_t *next; /* next node in hash chain */
42 } hash_node_t;
44 #define HASH_FAIL -1
46 void hash_init(hash_t *, int);
47 uintptr_t hash_lookup (const hash_t *, const char *);
48 uintptr_t hash_insert (hash_t *, const char *, uintptr_t);
49 uintptr_t hash_delete (hash_t *, const char *);
50 void hash_destroy(hash_t *);
51 char *hash_stats (hash_t *);
52 void hash_print(hash_t *,FILE *f);
53 void rebuild_table(hash_t *);
55 #ifdef __cplusplus
57 #endif
59 #define SVMT_HASH_H
60 #endif