unsorted lists can become sorted after removal

The old code only set the list to sorted when the lists size was <= 1
after the removal.
This commit is contained in:
2017-12-20 18:59:24 +01:00
parent c73d43c214
commit ec32e3f566
2 changed files with 61 additions and 2 deletions

View File

@@ -334,7 +334,12 @@ public final class IntList implements Serializable, Cloneable {
size = size - (toIndex - fromIndex);
sorted = size() <= 1 ? true : sorted; // lists of size 1 or smaller are always sorted
if (!sorted) {
sorted = true;
for (int i = 1; i < size && sorted; i++) {
sorted = data[i - 1] <= data[i];
}
}
}
/**
@@ -384,7 +389,12 @@ public final class IntList implements Serializable, Cloneable {
}
size = insertPosition;
sorted = size() <= 1 ? true : sorted; // lists of size 1 or smaller are always sorted
if (!sorted) {
sorted = true;
for (int i = 1; i < size && sorted; i++) {
sorted = data[i - 1] <= data[i];
}
}
}
/**