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:
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user