mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix bug in ArrayDeque
This commit is contained in:
parent
2c67cc3eb9
commit
fe6e796637
|
@ -262,11 +262,17 @@ public class TArrayDeque<E> extends TAbstractCollection<E> implements TDeque<E>
|
||||||
array[i + 1] = array[i];
|
array[i + 1] = array[i];
|
||||||
}
|
}
|
||||||
array[head++] = null;
|
array[head++] = null;
|
||||||
|
if (head >= array.length) {
|
||||||
|
head = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int i = index + 1; i < tail; ++i) {
|
for (int i = index + 1; i < tail; ++i) {
|
||||||
array[i - 1] = array[i];
|
array[i - 1] = array[i];
|
||||||
}
|
}
|
||||||
array[--tail] = null;
|
array[--tail] = null;
|
||||||
|
if (tail == 0) {
|
||||||
|
tail += array.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,6 +301,9 @@ public class TArrayDeque<E> extends TAbstractCollection<E> implements TDeque<E>
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@Override public void remove() {
|
@Override public void remove() {
|
||||||
|
if (lastIndex < 0) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
removeAt(lastIndex);
|
removeAt(lastIndex);
|
||||||
lastIndex = -1;
|
lastIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user