mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-05 18:30:26 +01:00
Reorder highest/lowest calculations - may fix issues with using remove()
This commit is contained in:
parent
c25a747500
commit
50a43d6116
@ -107,16 +107,15 @@ public class ByIdArray<T> implements Iterable<T> {
|
|||||||
public T remove(int index) {
|
public T remove(int index) {
|
||||||
if (index > elementData.length || elementData[index] == null)
|
if (index > elementData.length || elementData[index] == null)
|
||||||
return null;
|
return null;
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
T prev = (T) elementData[index];
|
||||||
|
elementData[index] = null;
|
||||||
|
--size;
|
||||||
++modCount;
|
++modCount;
|
||||||
if (index == highest)
|
if (index == highest)
|
||||||
recalcHighest();
|
recalcHighest();
|
||||||
if (index == lowest)
|
if (index == lowest)
|
||||||
recalcLowest();
|
recalcLowest();
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
T prev = (T) elementData[index];
|
|
||||||
elementData[index] = null;
|
|
||||||
if (prev != null)
|
|
||||||
--size;
|
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,8 +124,9 @@ public class ByIdArray<T> implements Iterable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void trimToSize() {
|
public void trimToSize() {
|
||||||
if (elementData.length > highest)
|
if (elementData.length > highest) {
|
||||||
elementData = Arrays.copyOf(elementData, highest + 1);
|
elementData = Arrays.copyOf(elementData, highest + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Itr implements Iterator<T> {
|
private class Itr implements Iterator<T> {
|
||||||
|
Loading…
Reference in New Issue
Block a user