GP-4221 - Fixed timing exception related to selecting table items before

the table has been sorted
This commit is contained in:
dragonmacher 2024-01-10 13:01:41 -05:00 committed by Ryan Kurtz
parent e17a03e2d1
commit ed1df869e3

View File

@ -139,7 +139,7 @@ public class TableData<ROW_OBJECT> implements Iterable<ROW_OBJECT> {
* @return the index
*/
public int indexOf(ROW_OBJECT t) {
if (!sortContext.isUnsorted()) {
if (isSorted()) {
Comparator<ROW_OBJECT> comparator = sortContext.getComparator();
return Collections.binarySearch(data, t, comparator);
}
@ -159,7 +159,7 @@ public class TableData<ROW_OBJECT> implements Iterable<ROW_OBJECT> {
source.remove(t);
}
if (sortContext.isUnsorted()) {
if (!isSorted()) {
return data.remove(t); // no sort; cannot binary search
}