| 72 | } |
| 73 | |
| 74 | size_t Bitmap::FirstUnset(size_t start) const { |
| 75 | if (start >= nbits_) { |
| 76 | return nbits_; |
| 77 | } |
| 78 | |
| 79 | // Mask to or-into first word to account for bits to skip in that word. |
| 80 | size_t mask = (1ull << (start % kBits)) - 1; |
| 81 | const size_t nwords = NumWords(nbits_); |
| 82 | for (size_t i = start / kBits; i < nwords; i++) { |
| 83 | Word word = word_[i] | mask; |
| 84 | mask = 0; // Only ignore bits in the first word we process. |
| 85 | size_t r = FindFirstSet(~word); |
| 86 | |
| 87 | if (r) { |
| 88 | size_t result = i * kBits + (r - 1); |
| 89 | if (result > nbits_) result = nbits_; |
| 90 | return result; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | return nbits_; |
| 95 | } |
| 96 | |
| 97 | string Bitmap::ToString() const { |
| 98 | string result; |