Accessor position must be establised via successful call to getFirst(), getLast() or locate() before you can call this method
| 472 | // Accessor position must be establised via successful call to getFirst(), |
| 473 | // getLast() or locate() before you can call this method |
| 474 | bool getNext() |
| 475 | { |
| 476 | if (bitmap->singular) |
| 477 | return false; |
| 478 | |
| 479 | // Use temporaries to avoid corrupting position if there is no next item in bitmap |
| 480 | BUNCH_T try_mask = bit_mask; |
| 481 | T try_value = current_value; |
| 482 | |
| 483 | // Proceed to next value |
| 484 | try_mask <<= 1; |
| 485 | try_value++; |
| 486 | |
| 487 | // Scan bucket forwards looking for a match |
| 488 | BUNCH_T tree_bits = treeAccessor.current().bits; |
| 489 | while (try_mask) |
| 490 | { |
| 491 | if (tree_bits & try_mask) |
| 492 | { |
| 493 | bit_mask = try_mask; |
| 494 | current_value = try_value; |
| 495 | return true; |
| 496 | } |
| 497 | try_mask <<= 1; |
| 498 | try_value++; |
| 499 | } |
| 500 | |
| 501 | // We scanned bucket, but found no match. |
| 502 | // No problem, scan the next bucket (there should be at least one bit set for a bucket) |
| 503 | if (!treeAccessor.getNext()) |
| 504 | return false; |
| 505 | |
| 506 | tree_bits = treeAccessor.current().bits; |
| 507 | try_mask = BUNCH_ONE; |
| 508 | try_value = treeAccessor.current().start_value; |
| 509 | do { |
| 510 | if (tree_bits & try_mask) { |
| 511 | bit_mask = try_mask; |
| 512 | current_value = try_value; |
| 513 | return true; |
| 514 | } |
| 515 | try_mask <<= 1; |
| 516 | try_value++; |
| 517 | } while (try_mask); |
| 518 | |
| 519 | // Bucket must contain one bit at least |
| 520 | fb_assert(false); |
| 521 | return false; // Absence of this statement makes GCC 3.4 generate wrong code here |
| 522 | } |
| 523 | |
| 524 | // Accessor position must be establised via successful call to getFirst(), |
| 525 | // getLast() or locate() before you can call this method |