3a29e3af8595efa3f7ac64a41d8d043e3a75a30f
[cacao.git] / src / toolbox / bitvector.h
1 /* src/toolbox/bitvector.h - bitvector header
2
3    Copyright (C) 2005, 2006 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Christian Ullrich
28
29    $Id: bitvector.h$
30
31 */
32
33
34 #ifndef _BITVECTOR_H
35 #define _BITVECTOR_H
36
37 #if !defined(NDEBUG)
38 #include <assert.h>
39
40 /* define BV_DEBUG_CHECK to activate the bound checks */
41
42 /* #define BV_DEBUG_CHECK */
43
44 /* no debug messages implemented till now */
45
46 /* #define BV_DEBUG_VERBOSE */
47 #endif
48
49 #if defined(BV_DEBUG_CHECK)
50 #define _BV_CHECK_BOUNDS(i,l,h) assert( ((i) >= (l)) && ((i) < (h)));
51 #define _BV_ASSERT(a) assert((a));
52 #else
53 #define _BV_CHECK_BOUNDS(i,l,h);
54 #define _BV_ASSERT(a);
55 #endif
56 typedef int *bitvector;
57
58 /* function prototypes */
59 char *bv_to_string(bitvector bv, char *string, int size);
60 bitvector bv_new(int size);           /* Create a new Bitvector for size Bits */
61                                       /* All bits are reset                   */
62 void bv_set_bit(bitvector bv, int bit);    /* set Bit bit of bitvector       */
63 void bv_reset_bit(bitvector bv, int bit);  /* reset Bit bit of bitvector     */
64 void bv_reset(bitvector bv, int size);     /* reset the whole bitvector      */
65 bool bv_is_empty(bitvector bv, int size);  /* Returns if no Bit is set       */
66 bool bv_get_bit(bitvector bv, int bit);    /* Returns if Bit bit is set      */
67 bool bv_equal(bitvector s1, bitvector s2, int size);
68
69 /* copy the whole bitvector    */
70
71 void bv_copy(bitvector dst, bitvector src, int size); 
72
73 /* d = s1 \ s2     */
74
75 void bv_minus(bitvector d, bitvector s1, bitvector s2, int size);
76
77 /* d = s1 union s2 */
78
79 void bv_union(bitvector d, bitvector s1, bitvector s2, int size);
80
81 #endif /* _BITVECTOR_H */
82
83
84 /*
85  * These are local overrides for various environment variables in Emacs.
86  * Please do not remove this and leave it at the end of the file, where
87  * Emacs will automagically detect them.
88  * ---------------------------------------------------------------------
89  * Local variables:
90  * mode: c
91  * indent-tabs-mode: t
92  * c-basic-offset: 4
93  * tab-width: 4
94  * End:
95  */