Initial commit
[cgperf.git] / hash-table.h
blob1fb95e378dd619343f3b567687f63d506b8c13bc
1 #ifndef CGPERF_HASH_TABLE_H
2 #define CGPERF_HASH_TABLE_H
3 #include <stdbool.h>
4 #include "c_fixing.h"
5 #include "keyword.h"
6 /*------------------------------------------------------------------------------------------------*/
7 #include "namespace/hash-table.h"
8 #include "namespace/keyword.h"
9 /*------------------------------------------------------------------------------------------------*/
10 /*{{{ constants and types */
11 /* to make double hashing efficient, there need to be enough spare entries */
12 enum {
13 ht_size_factor = 10
15 struct Hash_Table {
16 /*{{{ private */
17 /* a detail of the comparison function */
18 bool ignore_length;
19 /* Statistics: Number of collisions so far. */
20 u32 collisions;
21 /* log2(_size). */
22 u32 log_size;
23 /* size of the vector */
24 u32 size;
25 /* vector of entries */
26 struct Keyword **table;
27 /*}}} private -- END */
29 /*}}} constants and types -- END */
30 /*{{{ public static methods */
31 static struct Hash_Table *ht_new(u32 size, bool ignore_length);
32 static void ht_del(struct Hash_Table *t);
33 static struct Keyword *ht_insert(struct Hash_Table *t, struct Keyword *item);
34 static void ht_dump(struct Hash_Table *t);
35 /*}}} public static methods -- END */
36 /*{{{ private static methods */
37 static bool ht_equal(struct Hash_Table *t, struct Keyword *item1, struct Keyword *item2);
38 /*}}} private static methods -- END */
39 /*------------------------------------------------------------------------------------------------*/
40 #define EPILOG
41 #include "namespace/hash-table.h"
42 #include "namespace/keyword.h"
43 #undef EPILOG
44 /*------------------------------------------------------------------------------------------------*/
45 #endif