Tachyon (current)  Current Main Branch
hash.h
Go to the documentation of this file.
1 /*
2  * hash.h - This file contains prototypes for hash table code etc.
3  *
4  * (C) Copyright 1994-2022 John E. Stone
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * $Id: hash.h,v 1.5 2022/02/18 17:55:28 johns Exp $
8  */
9 
10 #ifndef HASH_H
11 #define HASH_H
12 
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 typedef struct rt_hash_t {
19  struct hash_node_t **bucket;
20  int size;
21  int entries;
22  int downshift;
23  int mask;
24 } rt_hash_t;
25 
30 #define HASH_FAIL -1
31 
32 void rt_hash_init(rt_hash_t *, int);
33 int rt_hash_lookup (rt_hash_t *, const char *);
34 int rt_hash_insert (rt_hash_t *, const char *, int);
35 int rt_hash_delete (rt_hash_t *, const char *);
37 char *rt_hash_stats (rt_hash_t *);
38 
39 #ifdef __cplusplus
40 }
41 #endif
42 
43 #endif
int mask
used to select bits for hashing
Definition: hash.h:23
struct hash_node_t ** bucket
array of hash nodes
Definition: hash.h:19
Definition: hash.h:18
int rt_hash_insert(rt_hash_t *, const char *, int)
Definition: hash.c:144
int entries
number of entries in table
Definition: hash.h:21
void rt_hash_destroy(rt_hash_t *)
Definition: hash.c:218
int rt_hash_delete(rt_hash_t *, const char *)
Definition: hash.c:177
void rt_hash_init(rt_hash_t *, int)
Definition: hash.c:87
int downshift
shift cound, used in hash function
Definition: hash.h:22
int size
size of the array
Definition: hash.h:20
struct rt_hash_t rt_hash_t
char * rt_hash_stats(rt_hash_t *)
Definition: hash.c:264
int rt_hash_lookup(rt_hash_t *, const char *)
Definition: hash.c:119