fix nth_element

This commit is contained in:
bolero-MURAKAMI 2014-04-06 18:59:20 +09:00
parent 098dd1721e
commit 13e0c9b5f5

View file

@ -132,24 +132,33 @@ namespace sprout {
return;
}
do {
bool not_sorted_flag = false;
if (n_swaps == 0) {
if (nth < i) {
j = m = first;
while (++j != i) {
if (comp(*j, *m)) {
not_sorted_flag = true;
break;
}
m = j;
}
if (not_sorted_flag) {
break;
}
return;
} else {
j = m = i;
while (++j != last) {
if (comp(*j, *m)) {
not_sorted_flag = true;
break;
}
m = j;
}
if (not_sorted_flag) {
break;
}
return;
}
}