137 value = value - ((value >> 1) & 0x5555555555555555);
138 value = (value & 0x3333333333333333) + ((value >> 2) & 0x3333333333333333);
139 return (((value + (value >> 4)) & 0xF0F0F0F0F0F0F0F) * 0x101010101010101) >> 56;
151 value = value - ((value >> 1) & 0x55555555);
152 value = (value & 0x33333333) + ((value >> 2) & 0x33333333);
153 return (((value + (value >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
165 value = value - ((value >> 1) & 0x5555);
166 value = (value & 0x3333) + ((value >> 2) & 0x3333);
171 value = (((value + (value >> 4)) & 0xF0F) * 0x101);
184 value = value - ((value >> 1) & 0x55u);
185 value = (value & 0x33u) + ((value >> 2) & 0x33u);
186 return (((value + (value >> 4)) & 0xFu) * 0x1);
197 void resize(
size_t length_in_bits);
223 bits[position >> 3] |= 1 << (position & 7);
237 bits[position >> 3] &= ~(1 << (position & 7));
253 return (bits[position >> 3] >> (position & 7)) & 0x01;
268 if (position < bits_long)
283 if (position < bits_long)
389 size_t index(
size_t which);
423 length = bits.size();
static size_t popcount(uint64_t value)
Count the number of bits set in value. This uses the parallel algorithm from here: https://graphics...
Definition: bitstring.h:135
void unsafe_setbit(size_t position)
Set the bit at position to 1.
Definition: bitstring.h:221
XOR two bitstrings together.
Definition: bitstring.h:53
void unsafe_unsetbit(size_t position)
Set the bit at position to 0.
Definition: bitstring.h:235
void bit_or(bitstring &answer, bitstring &with)
answer = this | with
Definition: bitstring.h:314
void unsetbit(size_t position)
Set the bit at position to 0.
Definition: bitstring.h:281
static size_t popcount(uint16_t value)
Definition: bitstring.h:163
void setbit(size_t position)
Set the bit at position to 1.
Definition: bitstring.h:266
static size_t popcount(uint32_t value)
Definition: bitstring.h:149
AND two bitstrings together.
Definition: bitstring.h:54
OR two bitstrings together.
Definition: bitstring.h:52
void bit_and_not(bitstring &answer, bitstring &with)
answer = this & ~with
Definition: bitstring.h:364
bitstring()
Constructor.
Definition: bitstring.h:110
void zero(void)
Set the bitstring to all zeros.
Definition: bitstring.cpp:70
virtual ~bitstring()
Destructor.
Definition: bitstring.h:121
Long bitstrings.
Definition: bitstring.h:36
virtual void operation(action op, bitstring &a, bitstring &b, bitstring &c)
operation
Definition: bitstring.cpp:101
size_t size(void) const
Return the length (in bits) of the bitstring.
Definition: bitstring.h:207
size_t index(size_t which)
Returns the bit position of the which-th set bit.
Definition: bitstring.cpp:153
uint64_t bitstring_word
bitstring_word is used as the underlying type for Boolean operations and for popcount() ...
Definition: bitstring.h:67
action
The action enum is used to pass a Boolean operation to operation().
Definition: bitstring.h:50
void one(void)
Set the bitstring to all ones.
Definition: bitstring.cpp:80
static size_t popcount(uint8_t value)
Definition: bitstring.h:182
uint8_t * serialise(size_t &length)
Return a serialised version of this object as an array of uint8_t.
Definition: bitstring.h:421
size_t popcount(void) const
Return the number of set bits in the bitstring. This uses popcount(bitstring_word) to do the count...
Definition: bitstring.cpp:25
void resize(size_t length_in_bits)
Set the length of the bitstring to length_in_bits. The new valid range is 0.. length_in_bits - 1...
Definition: bitstring.cpp:42
static void unittest(void)
Unit test this class.
Definition: bitstring.cpp:183
std::vector< uint8_t > bits
The underlying storage for the long bitstring.
Definition: bitstring.h:77
bool unsafe_getbit(size_t position) const
Return the state (0 or 1) of the bit at the given position.
Definition: bitstring.h:251
void bit_and(bitstring &answer, bitstring &with)
answer = this & with
Definition: bitstring.h:347
a AND ~ b
Definition: bitstring.h:55
Definition: compress_integer_elias_delta_simd.c:23
size_t bits_long
The length of the bitstring in bits.
Definition: bitstring.h:82
bool getbit(size_t position) const
Return the state (0 or 1) of the bit at the given position.
Definition: bitstring.h:298
void bit_xor(bitstring &answer, bitstring &with)
answer = this ^ with
Definition: bitstring.h:330