mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-12 13:44:07 +01:00
Extra validation code in Itr
This commit is contained in:
parent
a975b9ebf5
commit
8c28909411
@ -92,11 +92,13 @@ public class ByIdArray<T> implements Iterable<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void recalcHighest() {
|
private void recalcHighest() {
|
||||||
|
highest = elementData.length - 1;
|
||||||
while (highest != 0 && elementData[highest--] == null)
|
while (highest != 0 && elementData[highest--] == null)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recalcLowest() {
|
private void recalcLowest() {
|
||||||
|
lowest = 0;
|
||||||
while (elementData.length > lowest && highest > lowest && elementData[lowest++] == null)
|
while (elementData.length > lowest && highest > lowest && elementData[lowest++] == null)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@ -128,7 +130,16 @@ public class ByIdArray<T> implements Iterable<T> {
|
|||||||
|
|
||||||
private class Itr implements Iterator<T> {
|
private class Itr implements Iterator<T> {
|
||||||
private int expected = ByIdArray.this.modCount;
|
private int expected = ByIdArray.this.modCount;
|
||||||
private int idx = lowest;
|
private int idx;
|
||||||
|
{
|
||||||
|
if (lowest == Integer.MIN_VALUE || elementData[lowest] == null) {
|
||||||
|
recalcLowest();
|
||||||
|
}
|
||||||
|
idx = lowest;
|
||||||
|
if (elementData[lowest] == null) {
|
||||||
|
Messaging.log("lowest is still null!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
|
Loading…
Reference in New Issue
Block a user