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
70 typedef unsigned __int64
Base;
73 typedef unsigned long int Base;
78 static const unsigned int bpb =
79 static_cast<unsigned int>(CHAR_BIT *
sizeof(
Base));
82 void init(
bool set=
false);
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);
136 void init(A&
a,
unsigned int s,
bool set=
false);
138 unsigned int size(
void)
const;
140 bool get(
unsigned int i)
const;
142 void set(
unsigned int i);
144 void clear(
unsigned int i);
146 unsigned int next(
unsigned int i)
const;
151 void resize(A&
a,
unsigned int n,
bool set=
false);
165 bits =
set ? ~static_cast<
Base>(0) : static_cast<Base>(0);
173 return (
bits >> i) !=
static_cast<Base>(0U);
177 return (
bits & (static_cast<Base>(1U) << i)) !=
static_cast<Base>(0U);
181 bits |= (
static_cast<Base>(1U) << i);
185 bits &= ~(
static_cast<Base>(1U) << i);
189 assert(
bits != static_cast<Base>(0));
190 #if defined(GECODE_SUPPORT_MSVC_32)
193 _BitScanForward(&p,
bits >> i);
194 return static_cast<unsigned int>(p)+i;
195 #elif defined(GECODE_SUPPORT_MSVC_64)
198 _BitScanForward64(&p,
bits >> i);
199 return static_cast<unsigned int>(p)+i;
200 #elif defined(GECODE_HAS_BUILTIN_FFSL)
201 if ((
bpb == 32) || (
bpb == 64)) {
202 int p = __builtin_ffsl(
bits >> i);
204 return static_cast<unsigned int>(p-1)+i;
213 return bits == ~static_cast<
Base>(0U);
217 const Base mask = (
static_cast<Base>(1U) << i) -
static_cast<Base>(1U);
218 return (
bits & mask) == mask;
222 return bits ==
static_cast<Base>(0U);
226 const Base mask = (
static_cast<Base>(1U) << i) -
static_cast<Base>(1U);
227 return (
bits & mask) ==
static_cast<Base>(0U);
273 : sz(0), data(NULL) {}
300 assert((
sz == 0) && (
data == NULL));
332 unsigned int pos = i /
bpb;
333 unsigned int bit = i %
bpb;
339 }
while (!
data[pos]());
346 unsigned int bits =
sz %
bpb;
349 for (
unsigned int i=1;
i<
pos;
i++)
353 }
else if (
data[0].none()) {
354 for (
unsigned int i=1;
i<
pos;
i++)
362 if (
data[0].all(bits))
364 if (
data[0].none(bits))
371 #ifdef GECODE_SUPPORT_MSVC_32
372 #undef GECODE_SUPPORT_MSVC_32
374 #ifdef GECODE_SUPPORT_MSVC_64
375 #undef GECODE_SUPPORT_MSVC_64