| 588 | typename compare |
| 589 | > |
| 590 | bool static_map_kernel_1<domain,range,compare>:: |
| 591 | binary_search ( |
| 592 | const domain& item, |
| 593 | unsigned long& pos |
| 594 | ) const |
| 595 | { |
| 596 | unsigned long high = map_size; |
| 597 | unsigned long low = 0; |
| 598 | unsigned long p = map_size; |
| 599 | unsigned long idx; |
| 600 | while (p > 0) |
| 601 | { |
| 602 | p = (high-low)>>1; |
| 603 | idx = p+low; |
| 604 | if (comp(item , d[idx])) |
| 605 | { |
| 606 | high = idx; |
| 607 | } |
| 608 | else if (comp(d[idx] , item)) |
| 609 | { |
| 610 | low = idx; |
| 611 | } |
| 612 | else |
| 613 | { |
| 614 | pos = idx; |
| 615 | return true; |
| 616 | } |
| 617 | } |
| 618 | return false; |
| 619 | } |
| 620 | |
| 621 | // ---------------------------------------------------------------------------------------- |
| 622 | |