49 #pragma intrinsic(_BitScanForward)
50 #define GECODE_SUPPORT_MSVC_32
53 #if defined(_M_X64) || defined(_M_IA64)
54 #pragma intrinsic(_BitScanForward64)
55 #define GECODE_SUPPORT_MSVC_64
60 namespace Gecode {
namespace Support {
68 #ifdef GECODE_SUPPORT_MSVC_64
69 typedef unsigned __int64
Base;
72 typedef unsigned long int Base;
78 static const unsigned int bpb =
79 static_cast<unsigned int>(CHAR_BIT *
sizeof(
Base));
84 static unsigned int data(
unsigned int s);
88 bool get(
unsigned int i)
const;
90 void set(
unsigned int i);
92 void clear(
unsigned int i);
94 unsigned int next(
unsigned int i=0U)
const;
98 bool all(
unsigned int i)
const;
100 bool none(
void)
const;
102 bool none(
unsigned int i)
const;
122 bool _get(
unsigned int i)
const;
124 void _set(
unsigned int i);
141 void init(A&
a,
unsigned int s,
bool set=
false);
143 unsigned int size(
void)
const;
145 bool get(
unsigned int i)
const;
147 void set(
unsigned int i);
149 void clear(
unsigned int i);
151 unsigned int next(
unsigned int i)
const;
170 bits = set ? ~static_cast<
Base>(0) : static_cast<Base>(0);
174 return s == 0 ? 0 : ((s-1) /
bpb + 1);
178 return (
bits >> i) !=
static_cast<Base>(0U);
182 return (
bits & (static_cast<Base>(1U) << i)) !=
static_cast<Base>(0U);
186 bits |= (
static_cast<Base>(1U) << i);
190 bits &= ~(
static_cast<Base>(1U) << i);
194 assert(
bits != static_cast<Base>(0));
195 #if defined(GECODE_SUPPORT_MSVC_32)
198 _BitScanForward(&p,
bits >> i);
199 return static_cast<unsigned int>(
p)+i;
200 #elif defined(GECODE_SUPPORT_MSVC_64)
203 _BitScanForward64(&p,
bits >> i);
204 return static_cast<unsigned int>(
p)+i;
205 #elif defined(GECODE_HAS_BUILTIN_FFSL)
206 if ((
bpb == 32) || (
bpb == 64)) {
207 int p = __builtin_ffsl(
bits >> i);
209 return static_cast<unsigned int>(p-1)+i;
218 return bits == ~static_cast<
Base>(0U);
222 const Base mask = (
static_cast<Base>(1U) << i) -
static_cast<Base>(1U);
223 return (
bits & mask) == mask;
227 return bits ==
static_cast<Base>(0U);
231 const Base mask = (
static_cast<Base>(1U) << i) -
static_cast<Base>(1U);
232 return (
bits & mask) ==
static_cast<Base>(0U);
278 : sz(0), data(NULL) {}
305 assert((
sz == 0) && (
data == NULL));
337 unsigned int pos = i /
bpb;
338 unsigned int bit = i %
bpb;
344 }
while (!
data[pos]());
351 unsigned int bits =
sz %
bpb;
354 for (
unsigned int i=1;
i<
pos;
i++)
358 }
else if (
data[0].none()) {
359 for (
unsigned int i=1;
i<
pos;
i++)
367 if (
data[0].all(bits))
369 if (
data[0].none(bits))
376 #ifdef GECODE_SUPPORT_MSVC_32
377 #undef GECODE_SUPPORT_MSVC_32
379 #ifdef GECODE_SUPPORT_MSVC_64
380 #undef GECODE_SUPPORT_MSVC_64
void init(A &a, unsigned int s, bool set=false)
Initialize for s bits and allocator a (only after default constructor)
bool get(unsigned int i) const
Access value at bit i.
BitSetStatus
Status of a bitset.
void resize(A &a, unsigned int n, bool set=false)
Resize bitset to n elememts.
Some but not all bits set.
void clear(unsigned int i)
Clear bit i.
void set(unsigned int i)
Set bit i.
BitSetBase(void)
Default constructor (yields empty set)
bool all(void) const
Whether all bits are set.
bool pos(const View &x)
Test whether x is postive.
void clear(unsigned int i)
Clear bit i.
unsigned int next(unsigned int i=0U) const
Return next set bit with position greater or equal to i (there must be a bit)
void dispose(A &a)
Dispose memory for bit set.
unsigned long int Base
Basetype for bits.
int p
Number of positive literals for node type.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
unsigned int sz
Size of bitset (number of bits)
static unsigned int data(unsigned int s)
Get number of data elements for s bits.
void set(unsigned int i)
Set bit i.
BitSetStatus status(void) const
Return status of bitset.
void _set(unsigned int i)
Set bit i (no index check)
static const unsigned int bpb
Bits per base.
unsigned int next(unsigned int i) const
Return position greater or equal i of next set bit (i is allowed to be equal to size) ...
bool get(unsigned int i) const
Access value at bit i.
bool operator()(unsigned int i=0U) const
Test wether any bit with position greater or equal to i is set.
bool _get(unsigned int i) const
Access value at bit i (no index check)
unsigned int size(void) const
Return size of bitset (number of bits)
bool none(void) const
Whether no bits are set.
Gecode toplevel namespace
BitSetData * data
Stored bits.
struct Gecode::@512::NNF::@54::@56 a
For atomic nodes.
static const unsigned int bpb
Bits per base.
void init(bool set=false)
Initialize with all bits set if set.