[SVN r51644]
This commit is contained in:
Daniel James
2009-03-08 09:44:51 +00:00
parent 3e55934381
commit d8fb4f4c38

View File

@ -243,27 +243,27 @@ namespace test
node** merge_adjacent_ranges(node** first, node** second, node** merge_adjacent_ranges(node** first, node** second,
node** third, Less less) node** third, Less less)
{ {
while(true) { while(true) {
while(true) { while(true) {
if(first == second) return third; if(first == second) return third;
if(less((*second)->value_, (*first)->value_)) break; if(less((*second)->value_, (*first)->value_)) break;
first = &(*first)->next_; first = &(*first)->next_;
} }
swap_adjacent_ranges(first, second, third); swap_adjacent_ranges(first, second, third);
first = &(*first)->next_; first = &(*first)->next_;
// Since the two ranges we just swapped, the order is now: // Since the two ranges we just swapped, the order is now:
// first...third...second // first...third...second
while(true) { while(true) {
if(first == third) return second; if(first == third) return second;
if(!less((*first)->value_, (*third)->value_)) break; if(!less((*first)->value_, (*third)->value_)) break;
first = &(*first)->next_; first = &(*first)->next_;
} }
swap_adjacent_ranges(first, third, second); swap_adjacent_ranges(first, third, second);
first = &(*first)->next_; first = &(*first)->next_;
} }
} }