]> git.saurik.com Git - bison.git/blob - lib/ebitset.h
Use bitset operations when possible, not loops over bits.
[bison.git] / lib / ebitset.h
1 /* Functions to support ebitsets.
2 Copyright (C) 2002 Free Software Foundation, Inc.
3 Contributed by Michael Hayes (m.hayes@elec.canterbury.ac.nz).
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18
19 #ifndef _EBITSET_H
20 #define _EBITSET_H
21
22 #include "bitset-int.h"
23
24 /* Number of words to use for each element. */
25 #ifndef EBITSET_ELT_WORDS
26 #define EBITSET_ELT_WORDS 2
27 #endif
28
29 /* Number of bits stored in each element. */
30 #define EBITSET_ELT_BITS \
31 ((unsigned) (EBITSET_ELT_WORDS * BITSET_WORD_BITS))
32
33 /* Ebitset element. We use an array of bits. */
34 typedef struct ebitset_elt_struct
35 {
36 union
37 {
38 bitset_word words[EBITSET_ELT_WORDS]; /* Bits that are set. */
39 struct ebitset_elt_struct *next;
40 } u;
41 } ebitset_elt;
42
43
44 typedef ebitset_elt *ebitset_elts;
45
46 /* Head of ebitset linked list. */
47 typedef struct ebitset_struct
48 {
49 unsigned int size; /* Number of elements. */
50 ebitset_elts *elts; /* Expanding array of pointers to elements. */
51 } *ebitset;
52
53
54 extern int ebitset_bytes PARAMS ((bitset_bindex));
55
56 extern void ebitset_release_memory PARAMS ((void));
57
58 #endif