3 #include <cugar/basic/types.h> 13 template <u
int32 WORDS>
16 CUGAR_HOST_DEVICE
Bitmask() {
for (int32 i = 0; i < WORDS; ++i) bits[i] = 0; }
18 CUGAR_HOST_DEVICE
void set(
const int32 i)
20 const int32 word_index = i >> 5;
21 const int32 bit_index = i & 31;
22 bits[ word_index ] |= (1 << bit_index);
24 CUGAR_HOST_DEVICE
void clear(
const int32 i)
26 const int32 word_index = i >> 5;
27 const int32 bit_index = i & 31;
28 bits[ word_index ] &= ~(1 << bit_index);
30 CUGAR_HOST_DEVICE
bool get(
const int32 i)
const 32 const int32 word_index = i >> 5;
33 const int32 bit_index = i & 31;
34 return bits[ word_index ] & (1 << bit_index);
37 CUGAR_HOST_DEVICE int32 get_word(
const int32 i)
const {
return bits[i]; }
47 CUGAR_HOST_DEVICE
Bitmask() : bits(0) {}
49 CUGAR_HOST_DEVICE
void set(
const int32 i) { bits |= (1 << i); }
50 CUGAR_HOST_DEVICE
void clear(
const int32 i) { bits &= ~(1 << i); }
51 CUGAR_HOST_DEVICE
bool get(
const int32 i)
const {
return bits & (1 << i); }
53 CUGAR_HOST_DEVICE int32 get_word(
const int32 i)
const {
return bits; }
54 CUGAR_HOST_DEVICE int32 get_bits(
const int32 offset)
const {
return bits >> offset; }
64 CUGAR_HOST_DEVICE
Bitmask() { bits0 = bits1 = 0; }
66 CUGAR_HOST_DEVICE
void set(
const int32 i)
68 const int32 word_index = i >> 5;
69 const int32 bit_index = i & 31;
70 if (word_index == 0) bits0 |= (1 << bit_index);
71 if (word_index != 0) bits1 |= (1 << bit_index);
73 CUGAR_HOST_DEVICE
void clear(
const int32 i)
75 const int32 word_index = i >> 5;
76 const int32 bit_index = i & 31;
77 if (word_index == 0) bits0 &= ~(1 << bit_index);
78 if (word_index != 0) bits1 &= ~(1 << bit_index);
80 CUGAR_HOST_DEVICE
bool get(
const int32 i)
const 82 const int32 word_index = i >> 5;
83 const int32 bit_index = i & 31;
84 return (word_index ? bits1 : bits0) & (1 << bit_index);
87 CUGAR_HOST_DEVICE int32 get_word(
const int32 i)
const {
return i ? bits1 : bits0; }
89 CUGAR_HOST_DEVICE int32 get_bits(
const int32 offset)
const 91 const int32 word_index = offset >> 5;
92 const int32 bit_offset = offset & 31;
93 return (word_index ? bits1 : bits0) >> bit_offset;
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38