22 #ifndef OTAWA_DFA_BITSET_H
23 #define OTAWA_DFA_BITSET_H
25 #define OTAWA_BITSET_SIZE
28 #if defined(OTAWA_BITSET_WAH) || defined(OTAWA_BITSET_BOTH)
29 # include <elm/util/WAHVector.h>
31 #if defined(OTAWA_BITSET_BOTH) || !defined(OTAWA_BITSET_WAH)
32 # include <elm/util/BitVector.h>
34 #ifdef OTAWA_BITSET_BOTH
35 # include <elm/util/WAHVector.h>
36 # include <elm/util/BitVector.h>
40 Both(
int s,
bool v =
false): bvec(s, v), wvec(s, v) { }
41 inline int __size(
void)
const {
return bvec.__size() + wvec.__size(); }
42 inline bool isEmpty(
void)
const { ASSERT(bvec.isEmpty() && wvec.isEmpty());
return bvec.isEmpty(); }
43 inline int countBits(
void)
const { ASSERT(bvec.countBits() == wvec.countBits());
return bvec.countBits(); };
44 inline int size(
void)
const { ASSERT(bvec.size() == wvec.size());
return bvec.size(); }
45 inline void set(
void) { bvec.set(); wvec.set(); check(); }
46 inline void clear(
void) { bvec.clear(); wvec.clear(); check(); }
47 inline bool bit(
int i)
const { ASSERT(bvec.bit(i) == wvec.bit(i));
return bvec.bit(i); }
48 inline void set(
int i) { bvec.set(i); wvec.set(i); check(); }
49 inline void clear(
int i) { bvec.clear(i); wvec.clear(i); check(); }
50 inline bool equals(
const Both& b)
const { ASSERT(bvec.equals(b.bvec) == wvec.equals(b.wvec));
return bvec.equals(b.bvec); }
51 inline bool includes(
const Both& b)
const { ASSERT(bvec.includes(b.bvec) == wvec.includes(b.wvec));
return bvec.includes(b.bvec); }
52 inline bool includesStrictly(
const Both& b)
const { ASSERT(bvec.includesStrictly(b.bvec) == wvec.includesStrictly(b.wvec));
return bvec.includesStrictly(b.bvec); }
53 inline void applyNot(
void) { bvec.applyNot(); wvec.applyNot(); check(); }
54 inline void applyOr(
const Both& b) { bvec.applyOr(b.bvec); wvec.applyOr(b.wvec); check(); }
55 inline void applyAnd(
const Both& b) { bvec.applyAnd(b.bvec); wvec.applyAnd(b.wvec); check(); }
56 inline void applyReset(
const Both& b) { bvec.applyReset(b.bvec); wvec.applyReset(b.wvec); check(); }
57 inline Both makeNot(
void)
const { Both b; b.bvec = bvec.makeNot(); b.wvec = wvec.makeNot(); b.check();
return b; }
58 inline Both makeOr(
const Both& b)
const { Both r; r.bvec = bvec.makeOr(b.bvec); r.wvec = wvec.makeOr(b.wvec); r.check();
return r; }
59 inline Both makeAnd(
const Both& b)
const { Both r; r.bvec = bvec.makeAnd(b.bvec); r.wvec = wvec.makeAnd(b.wvec); r.check();
return r; }
60 inline Both makeReset(
const Both& b)
const { Both r; r.bvec = bvec.makeReset(b.bvec); r.wvec = wvec.makeReset(b.wvec); r.check();
return r; }
72 ASSERT(bvec.size() == wvec.size());
73 for(
int i = 0; i < bvec.size(); i++)
74 ASSERT(bvec[i] == wvec[i]);
79 namespace otawa {
namespace dfa {
83 # ifdef OTAWA_BITSET_WAH
85 # elif defined(OTAWA_BITSET_BOTH)
92 # ifdef OTAWA_BITSET_SIZE
94 # define OTAWA_BITSET_ALLOC { __total_size += vec.__size(); __used_size += vec.__size(); if(__used_size >= __max_size) __max_size = __used_size; }
95 # define OTAWA_BITSET_FREE { __used_size -= vec.__size(); }
97 # define OTAWA_BITSET_ALLOC
98 # define OTAWA_BITSET_FREE
164 for(
int i = 0; i < bits.
size(); i++)
179 #endif // OTAWA_DFA_BITSET_H
bool operator!=(const BitSet &set) const
Same as !equals().
Definition: BitSet.h:145
bool includes(const BitVector &vec) const
BitSet doComp(void) const
Compute a bit set complement of the current one.
Definition: BitSet.h:125
void set(T *target, int size, const T &v)
static int __total_size
Definition: BitSet.h:93
Iterator(const BitSet &set)
Build an iterator on the items of the given bit set.
Definition: BitSet.h:154
BitVector makeOr(const BitVector &vec) const
void empty(void)
Remove all items from the bit set.
Definition: BitSet.h:109
bool includesStrictly(const BitSet &set) const
Test if the current bit set contains strictly the given one, that is, both bit sets are equals...
Definition: BitSet.h:117
BitSet & operator+=(int index)
Same as add(int).
Definition: BitSet.h:132
BitSet & operator&=(const BitSet &set)
Same as remove(const BitSet&).
Definition: BitSet.h:140
BitVector makeReset(const BitVector &vec) const
bool equals(const BitVector &vec) const
bool operator==(const BitSet &set) const
Same as equals().
Definition: BitSet.h:144
bool operator<=(const BitSet &set) const
Same as !includesStrictly().
Definition: BitSet.h:147
BitVector makeAnd(const BitVector &vec) const
This class implements a set as a bit vector.
Definition: BitSet.h:82
bool isFull(void) const
Test if the bit set contains all existing items.
Definition: BitSet.h:107
BitSet operator&(const BitSet &set)
Same as doInter().
Definition: BitSet.h:142
BitVector makeNot(void) const
elm::io::Output & operator<<(elm::io::Output &output, const BitSet &bits)
Definition: BitSet.h:161
BitSet(const vec_t &ivec)
Definition: BitSet.h:158
BitSet operator-(const BitSet &set)
Same as doDiff().
Definition: BitSet.h:137
BitSet & operator=(const BitSet &set)
Assignment with bit sets.
Definition: BitSet.h:130
BitSet & operator-=(int index)
Same as remove(int).
Definition: BitSet.h:134
#define OTAWA_BITSET_ALLOC
Definition: BitSet.h:94
bool includesStrictly(const BitVector &vec) const
int countBits(void) const
bool contains(int index) const
Test if the bit set contains an item.
Definition: BitSet.h:111
BitSet(void)
Definition: BitSet.h:101
bool bit(int index) const
static int __used_size
Definition: BitSet.h:93
BitSet(int size)
Build a bitset with the given size.
Definition: BitSet.h:102
BitSet operator+(const BitSet &set)
Same as doUnion().
Definition: BitSet.h:136
int size(void) const
Definition: BitSet.h:119
BitSet(const BitSet &set)
Build a bit set from by copying an existing one.
Definition: BitSet.h:103
void mask(const BitSet &set)
Keep only in this set the items also containted in the given one (performs intersection operation)...
Definition: BitSet.h:122
OneIterator(const BitVector &bit_vector)
BitSet operator|(const BitSet &set)
Same as doUnion().
Definition: BitSet.h:141
int count(void) const
Definition: BitSet.h:123
BitSet doInter(const BitSet &set) const
Build a new bit set as intersection between the current and the given one.
Definition: BitSet.h:127
vec_t vec
Definition: BitSet.h:90
void complement(void)
Complement the current bit set.
Definition: BitSet.h:118
BitSet doDiff(const BitSet &set) const
Build a new bit set as difference between the current and the given one.
Definition: BitSet.h:128
BitSet & operator+=(const BitSet &set)
Same as add(const BitSet&).
Definition: BitSet.h:133
void set(int index) const
void clear(int index) const
bool isEmpty(void) const
Test if the bit set is empty.
Definition: BitSet.h:106
bool operator<(const BitSet &set) const
Same as !includes().
Definition: BitSet.h:149
bool operator>(const BitSet &set) const
Same as includesStrictly().
Definition: BitSet.h:148
void clear(T *target, int size)
bool equals(const BitSet &set) const
Test if two bit sets are equals.
Definition: BitSet.h:115
elm::BitVector vec_t
Definition: BitSet.h:88
BitSet & operator|=(const BitSet &set)
Same as add(const BitSet&).
Definition: BitSet.h:139
void applyReset(const BitVector &vec)
~BitSet(void)
Definition: BitSet.h:104
BitSet doUnion(const BitSet &set) const
Build a new bit set as union between the current and the given one.
Definition: BitSet.h:126
Iterator on the item contained in a bit set.
Definition: BitSet.h:152
bool operator>=(const BitSet &set) const
Same as includes().
Definition: BitSet.h:146
void fill(void)
Fill the bit set with all items.
Definition: BitSet.h:108
void applyOr(const BitVector &vec)
BitSet & operator-=(const BitSet &set)
Same as remove(const BitSet&).
Definition: BitSet.h:135
void add(const BitSet &set)
Add the items of the given bit set to the current one.
Definition: BitSet.h:120
void applyAnd(const BitVector &vec)
bool includes(const BitSet &set) const
Test if the current bit set contains the given one.
Definition: BitSet.h:116
void add(int index)
Add an item to the bit set.
Definition: BitSet.h:112
static int __max_size
Definition: BitSet.h:93
#define OTAWA_BITSET_FREE
Definition: BitSet.h:95