25 int lower =
static_cast<int>(value);
26 if ((bit = ffs(lower)) > 0)
29 int upper = value >> 32;
30 if ((bit = ffs(upper)) > 0)
50 if ((value & 0xFFFF0000U) == 0) {
54 if ((value & 0xFF000000U) == 0) {
58 if ((value & 0xF0000000U) == 0) {
62 if ((value & 0xC0000000U) == 0) {
66 if ((value & 0x80000000U) == 0) {
82 int upper = value >> 32;
86 int lower =
static_cast<int>(value);
117 return (idx * 64 + offset);
127 if (idx >= blocks_.size())
128 blocks_.resize(idx + 1);
138 if (idx < blocks_.size()) {
148 if (idx < blocks_.size()) {
149 return ((blocks_[idx] & (1LL <<
block_offset(pos))) != 0);
166 return (blocks_.size() == 0);
173 return (blocks_.size() == 0);
180 return (blocks_.size() != 0);
188 return blocks_.size() * 64;
196 for (
size_t idx = 0; idx < blocks_.size(); idx++) {
210 if (blocks_.size() == 0)
213 for (
size_t idx = blocks_.size() - 1; idx > 0; idx--) {
214 if (blocks_[idx] != 0) {
215 blocks_.resize(idx + 1);
220 if (blocks_[0] != 0) {
233 size_t mysize = blocks_.size();
235 assert(blocks_[mysize -1] != 0);
243 for (
size_t idx = 0; idx < blocks_.size(); idx++) {
259 if (idx >= blocks_.size())
265 uint64_t temp = blocks_[idx] & ~((1LL << (
block_offset(pos) + 1)) - 1);
273 for (idx++; idx < blocks_.size(); idx++) {
289 if (blocks_.size() == 0)
292 size_t idx = blocks_.size() - 1;
308 for (
size_t idx = 0; idx < blocks_.size(); idx++) {
328 if (idx >= blocks_.size())
334 uint64_t temp = blocks_[idx] | ((1LL << (
block_offset(pos) + 1)) - 1);
342 for (idx++; idx < blocks_.size(); idx++) {
355 size_t minsize = std::min(blocks_.size(), rhs.
blocks_.size());
356 for (
size_t idx = 0; idx < minsize; idx++) {
357 if (blocks_[idx] & rhs.
blocks_[idx])
370 if (blocks_.size() != rhs.
blocks_.size())
372 for (
size_t idx = 0; idx < blocks_.size(); idx++) {
373 if (blocks_[idx] != rhs.
blocks_[idx])
401 size_t minsize = std::min(blocks_.size(), rhs.
blocks_.size());
402 size_t maxsize = std::max(blocks_.size(), rhs.
blocks_.size());
406 for (
size_t idx = 0; idx < minsize; idx++) {
411 for (
size_t idx = minsize; idx < blocks_.size(); idx++) {
412 temp.
blocks_[idx] = blocks_[idx];
416 for (
size_t idx = minsize; idx < rhs.
blocks_.size(); idx++) {
431 size_t minsize = std::min(blocks_.size(), rhs.
blocks_.size());
432 for (
size_t idx = 0; idx < minsize; idx++) {
433 blocks_[idx] &= rhs.
blocks_[idx];
435 for (
size_t idx = minsize; idx < blocks_.size(); idx++) {
450 if (blocks_.size() < rhs.
blocks_.size())
451 blocks_.resize(rhs.
blocks_.size());
452 for (
size_t idx = 0; idx < rhs.
blocks_.size(); idx++) {
453 blocks_[idx] |= rhs.
blocks_[idx];
463 this->operator|=(rhs);
471 size_t minsize = std::min(blocks_.size(), rhs.
blocks_.size());
472 for (
size_t idx = 0; idx < minsize; idx++) {
473 blocks_[idx] &= ~rhs.
blocks_[idx];
488 blocks_.resize(lhs.
blocks_.size());
489 size_t minsize = std::min(blocks_.size(), rhs.
blocks_.size());
490 for (
size_t idx = 0; idx < minsize; idx++) {
493 for (
size_t idx = minsize; idx < lhs.
blocks_.size(); idx++) {
494 blocks_[idx] = lhs.
blocks_[idx];
511 size_t minsize = std::min(lhs.
blocks_.size(), rhs.
blocks_.size());
516 for (
size_t idx = minsize - 1; idx > 0; idx--) {
518 if (blocks_.size() == 0)
519 blocks_.resize(idx + 1);
525 if (blocks_.size() == 0)
537 if (blocks_.size() < rhs.
blocks_.size())
539 for (
size_t idx = 0; idx < rhs.
blocks_.size(); idx++) {
540 if (rhs.
blocks_[idx] & ~blocks_[idx])
552 size_t last_pos = find_last();
556 string str(last_pos + 1,
'0');
557 for (
size_t pos = find_first(); pos !=
BitSet::npos; pos = find_next(pos)) {
575 if (str.length() == 0)
578 for (
size_t str_idx = str.length() - 1; str_idx > 0; str_idx--) {
579 if (str[str_idx] ==
'1')
601 last_pos = pos, pos = find_next(pos)) {
604 }
else if (pos == last_pos + 1) {
void FromString(std::string str)
bool test(size_t pos) const
static int find_first_clear64(uint64_t value)
BitSet & reset(size_t pos)
std::string ToString() const
void Reset(const BitSet &rhs)
std::vector< uint64_t > blocks_
BitSet operator|(const BitSet &rhs) const
void BuildIntersection(const BitSet &lhs, const BitSet &rhs)
static int find_last_set64(uint64_t value)
static int find_last_set32(uint32_t value)
bool Contains(const BitSet &rhs) const
bool operator==(const BitSet &rhs) const
static size_t bit_position(size_t idx, size_t offset)
size_t find_first_clear() const
BitSet operator&(const BitSet &rhs) const
static const std::string integerToString(const NumberType &num)
bool operator==(const WaterMarkInfo &lhs, const WaterMarkInfo &rhs)
BitSet & operator|=(const BitSet &rhs)
size_t find_next_clear(size_t pos) const
void Set(const BitSet &rhs)
bool operator!=(const BitSet &rhs) const
static int num_bits_set(uint64_t value)
static int find_first_set64(uint64_t value)
size_t find_first() const
void BuildComplement(const BitSet &lhs, const BitSet &rhs)
bool intersects(const BitSet &rhs) const
size_t find_next(size_t pos) const
std::string ToNumberedString() const
static size_t block_offset(size_t pos)
static size_t block_index(size_t pos)
BitSet & operator&=(const BitSet &rhs)