fix VariantList type
There was a confusion on utils::bitset<> API, it specifies the number of words to use, not then number of bits in the set. VariantList was sized to store 8192 bits instead of 128.
This commit is contained in:
committed by
Mathias Agopian
parent
f9d7d60f7d
commit
4b1a451804
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/compiler.h>
|
||||
#include <utils/debug.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
@@ -59,10 +60,12 @@ public:
|
||||
}
|
||||
|
||||
T getBitsAt(size_t n) const noexcept {
|
||||
assert_invariant(n<N);
|
||||
return storage[n];
|
||||
}
|
||||
|
||||
T& getBitsAt(size_t n) noexcept {
|
||||
assert_invariant(n<N);
|
||||
return storage[n];
|
||||
}
|
||||
|
||||
@@ -93,19 +96,23 @@ public:
|
||||
bool test(size_t bit) const noexcept { return operator[](bit); }
|
||||
|
||||
void set(size_t b) noexcept {
|
||||
assert_invariant(b / BITS_PER_WORD < N);
|
||||
storage[b / BITS_PER_WORD] |= T(1) << (b % BITS_PER_WORD);
|
||||
}
|
||||
|
||||
void set(size_t b, bool value) noexcept {
|
||||
assert_invariant(b / BITS_PER_WORD < N);
|
||||
storage[b / BITS_PER_WORD] &= ~(T(1) << (b % BITS_PER_WORD));
|
||||
storage[b / BITS_PER_WORD] |= T(value) << (b % BITS_PER_WORD);
|
||||
}
|
||||
|
||||
void unset(size_t b) noexcept {
|
||||
assert_invariant(b / BITS_PER_WORD < N);
|
||||
storage[b / BITS_PER_WORD] &= ~(T(1) << (b % BITS_PER_WORD));
|
||||
}
|
||||
|
||||
void flip(size_t b) noexcept {
|
||||
assert_invariant(b / BITS_PER_WORD < N);
|
||||
storage[b / BITS_PER_WORD] ^= T(1) << (b % BITS_PER_WORD);
|
||||
}
|
||||
|
||||
@@ -115,6 +122,7 @@ public:
|
||||
}
|
||||
|
||||
bool operator[](size_t b) const noexcept {
|
||||
assert_invariant(b / BITS_PER_WORD < N);
|
||||
return bool(storage[b / BITS_PER_WORD] & (T(1) << (b % BITS_PER_WORD)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user