mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix updating size in LinkedList.remove (fix #226).
This commit is contained in:
parent
2a3b0cd597
commit
8c3f071f88
|
@ -348,7 +348,6 @@ public class TLinkedList<E> extends TAbstractSequentialList<E> implements TDeque
|
||||||
} else if (currentEntry == nextEntry) {
|
} else if (currentEntry == nextEntry) {
|
||||||
nextEntry = hasPrevious() ? prevEntry.next : null;
|
nextEntry = hasPrevious() ? prevEntry.next : null;
|
||||||
}
|
}
|
||||||
--size;
|
|
||||||
version = modCount;
|
version = modCount;
|
||||||
currentEntry = null;
|
currentEntry = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ public class LinkedListTest {
|
||||||
assertEquals(2, iter.nextIndex());
|
assertEquals(2, iter.nextIndex());
|
||||||
assertEquals("a", iter.next());
|
assertEquals("a", iter.next());
|
||||||
assertArrayEquals(new String[] { "1", "2", "a", "b" }, list.toArray(new String[0]));
|
assertArrayEquals(new String[] { "1", "2", "a", "b" }, list.toArray(new String[0]));
|
||||||
|
assertEquals(4, list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -138,6 +139,7 @@ public class LinkedListTest {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
assertEquals(1, iter.nextIndex());
|
assertEquals(1, iter.nextIndex());
|
||||||
assertEquals("3", iter.next());
|
assertEquals("3", iter.next());
|
||||||
|
assertEquals(4, list.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test(expected = IllegalStateException.class)
|
||||||
|
@ -195,7 +197,7 @@ public class LinkedListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removesFirstOccurence() {
|
public void removesFirstOccurrence() {
|
||||||
LinkedList<String> list = new LinkedList<>();
|
LinkedList<String> list = new LinkedList<>();
|
||||||
list.addAll(Arrays.asList("1", "2", "3", "1", "2"));
|
list.addAll(Arrays.asList("1", "2", "3", "1", "2"));
|
||||||
assertFalse(list.removeFirstOccurrence("*"));
|
assertFalse(list.removeFirstOccurrence("*"));
|
||||||
|
@ -205,7 +207,7 @@ public class LinkedListTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void removesLastOccurence() {
|
public void removesLastOccurrence() {
|
||||||
LinkedList<String> list = new LinkedList<>();
|
LinkedList<String> list = new LinkedList<>();
|
||||||
list.addAll(Arrays.asList("1", "2", "3", "1", "2"));
|
list.addAll(Arrays.asList("1", "2", "3", "1", "2"));
|
||||||
assertFalse(list.removeLastOccurrence("*"));
|
assertFalse(list.removeLastOccurrence("*"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user