Skip to content

Commit

Permalink
Reorder highest/lowest calculations - may fix issues with using remove()
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Sep 10, 2013
1 parent c99825e commit c7a576d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/citizensnpcs/util/ByIdArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ private void recalcLowest() {
public T remove(int index) {
if (index > elementData.length || elementData[index] == null)
return null;
@SuppressWarnings("unchecked")
T prev = (T) elementData[index];
elementData[index] = null;
--size;
++modCount;
if (index == highest)
recalcHighest();
if (index == lowest)
recalcLowest();
@SuppressWarnings("unchecked")
T prev = (T) elementData[index];
elementData[index] = null;
if (prev != null)
--size;
return prev;
}

Expand All @@ -125,8 +124,9 @@ public int size() {
}

public void trimToSize() {
if (elementData.length > highest)
if (elementData.length > highest) {
elementData = Arrays.copyOf(elementData, highest + 1);
}
}

private class Itr implements Iterator<T> {
Expand Down

0 comments on commit c7a576d

Please sign in to comment.