1 /***********************************************************************
7 * Copyright (C) 2002 Roaring Penguin Software Inc.
11 ***********************************************************************/
17 /* Fixed-size hash tables for now */
18 #define HASHTAB_SIZE 67
21 typedef struct hash_bucket_t
{
22 struct hash_bucket_t
*next
;
23 struct hash_bucket_t
*prev
;
28 typedef struct hash_table_t
{
29 hash_bucket
*buckets
[HASHTAB_SIZE
];
31 unsigned int (*compute_hash
)(void *data
);
32 int (*compare
)(void *item1
, void *item2
);
37 void hash_init(hash_table
*tab
,
39 unsigned int (*compute
)(void *data
),
40 int (*compare
)(void *item1
, void *item2
));
41 void hash_insert(hash_table
*tab
, void *item
);
42 void hash_remove(hash_table
*tab
, void *item
);
43 void *hash_find(hash_table
*tab
, void *item
);
44 void *hash_find_next(hash_table
*tab
, void *item
);
45 size_t hash_num_entries(hash_table
*tab
);
47 /* Iteration functions */
48 void *hash_start(hash_table
*tab
, void **cursor
);
49 void *hash_next(hash_table
*tab
, void **cursor
);
51 /* Utility function: hashpjw for strings */
52 unsigned int hash_pjw(char const *str
);