1
/* @(#)hash.h 19.1 (ESO-IPG) 02/25/03 13:49:34 */
2
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
.VERSION 1.0 18-Apr-1988: Creation
7
.AUTHOR Francois Ochsenbein [ESO-IPG]
8
.CATEGORY General Hash-Table Definition
9
.COMMENTS A hash table is described by a header.
11
------------------------------------------------------------*/
20
/*===========================================================================
22
*===========================================================================*/
24
typedef struct s_h_item{
25
struct s_h_item *next; /* Next definition in chain */
26
int leq; /* Length of Equivalence string */
27
unsigned char ls; /* Length of symbol */
28
char strings[2]; /* Strings terminated with EOS */
32
int size; /* Number of items in table */
33
int symbols; /* Number of symbols */
34
int collisions; /* Number of collisions */
35
H_ITEM *start[1]; /* Starting points of chains */
39
/*===========================================================================
40
* Related functions and macros
41
*===========================================================================*/
42
int h_factor (int n); /* Hash factor (2 is default) */
43
H_TABLE *h_create (int size); /* Size is adjusted to prime */
44
int h_clear (H_TABLE *ht); /* Make table empty */
45
int h_log (H_TABLE *ht); /* Log the table contents */
46
H_ITEM *h_look (H_TABLE *ht, char *symbol, int len);
47
H_ITEM *h_add (H_TABLE *ht, char *symbol, int ls, char *eq, int leq);
48
int h_remove (H_TABLE *ht, char *symbol, int len);
49
char *h_get (H_TABLE *ht, char *symbol, int len);
53
H_ITEM *h_add(), *h_look();
57
#define H_Create(size) h_create(size)
58
#define H_Clear(ht) h_clear(ht)
59
#define H_Lookup(ht,s) h_look(ht,s,strlen(s))
60
#define H_Gets(ht,s) h_get(ht,s,strlen(s))
61
#define H_Add(ht,s,eq) h_add(ht,s,strlen(s),eq,strlen(eq))
62
#define H_Remove(ht,s) h_remove(ht,s,strlen(s))