| 394 | } |
| 395 | |
| 396 | inline int32_t findFirstBit(const uint64_t* bits, int32_t begin, int32_t end) { |
| 397 | int32_t found = -1; |
| 398 | testWords( |
| 399 | begin, |
| 400 | end, |
| 401 | [bits, &found](int32_t idx, uint64_t mask) { |
| 402 | uint64_t word = bits[idx] & mask; |
| 403 | if (word) { |
| 404 | found = idx * 64 + __builtin_ctzll(word); |
| 405 | return false; |
| 406 | } |
| 407 | return true; |
| 408 | }, |
| 409 | [bits, &found](int32_t idx) { |
| 410 | uint64_t word = bits[idx]; |
| 411 | if (word) { |
| 412 | found = idx * 64 + __builtin_ctzll(word); |
| 413 | return false; |
| 414 | } |
| 415 | return true; |
| 416 | }); |
| 417 | return found; |
| 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Invokes a function for each set or unset bit. |