type: Make an assert()ion independent of the last entry of an enum.
[cparser] / adt / hashset.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @date    16.03.2007
9  * @brief   Generic hashset functions
10  * @author  Matthias Braun
11  *
12  * You have to specialize this header by defining HashSet, HashSetIterator and
13  * ValueType
14  */
15 #ifdef HashSet
16
17 #include <stdlib.h>
18
19 #ifdef DO_REHASH
20 #define HashSetEntry ValueType
21 #else
22 typedef struct HashSetEntry {
23         ValueType data;
24         unsigned hash;
25 } HashSetEntry;
26 #endif
27
28 struct HashSet {
29         HashSetEntry *entries;
30         size_t num_buckets;
31         size_t enlarge_threshold;
32         size_t shrink_threshold;
33         size_t num_elements;
34         size_t num_deleted;
35         int consider_shrink;
36 #ifndef NDEBUG
37         unsigned entries_version;
38 #endif
39 #ifdef ADDITIONAL_DATA
40         ADDITIONAL_DATA
41 #endif
42 };
43
44 #ifdef HashSetIterator
45 struct HashSetIterator {
46         HashSetEntry *current_bucket;
47         HashSetEntry *end;
48 #ifndef NDEBUG
49         const struct HashSet *set;
50         unsigned entries_version;
51 #endif
52 };
53 #endif
54
55 #ifdef DO_REHASH
56 #undef HashSetEntry
57 #endif
58
59 #endif