find_next - Returns the index of the next set bit starting from the "Curr" bit. Returns -1 if the next set bit is not found.
| 378 | /// find_next - Returns the index of the next set bit starting from the |
| 379 | /// "Curr" bit. Returns -1 if the next set bit is not found. |
| 380 | int find_next(unsigned Curr) const |
| 381 | { |
| 382 | if (Curr >= BITS_PER_ELEMENT) |
| 383 | return -1; |
| 384 | |
| 385 | unsigned WordPos = Curr / BITWORD_SIZE; |
| 386 | unsigned BitPos = Curr % BITWORD_SIZE; |
| 387 | BitWord Copy = Bits[WordPos]; |
| 388 | assert(WordPos <= BITWORDS_PER_ELEMENT |
| 389 | && "Word Position outside of element"); |
| 390 | |
| 391 | // Mask off previous bits. |
| 392 | Copy &= ~0UL << BitPos; |
| 393 | |
| 394 | if (Copy != 0) |
| 395 | return WordPos * BITWORD_SIZE + countTrailingZeros(Copy); |
| 396 | |
| 397 | // Check subsequent words. |
| 398 | for (unsigned i = WordPos+1; i < BITWORDS_PER_ELEMENT; ++i) |
| 399 | if (Bits[i] != 0) |
| 400 | return i * BITWORD_SIZE + countTrailingZeros(Bits[i]); |
| 401 | return -1; |
| 402 | } |
| 403 | |
| 404 | // Union this element with RHS and return true if this one changed. |
| 405 | bool unionWith(const SparseBitVectorElement &RHS) |
no test coverage detected