ChunkList extends AbstractSequentialList<E> { public ChunkList() { } ChunkList();  ChunkList(Collection<E> collection); @Override ListIterator<E> listIterator(int index); @Override int size(); @Override boolean add(E element); @Override void add(int index, E element);  }
@Test public void testChunkList() { final ChunkList<Integer> list = new ChunkList<Integer>(); assertEquals(0, list.size()); assertTrue(list.isEmpty()); assertEquals("[]", list.toString()); try { list.remove(0); fail("expected exception"); } catch (IndexOutOfBoundsException e) { } list.add(7); assertEquals(1, list.size()); assertEquals(7, (int) list.get(0)); assertFalse(list.isEmpty()); assertEquals("[7]", list.toString()); list.add(9); list.add(null); list.add(11); assertEquals(4, list.size()); assertEquals(7, (int) list.get(0)); assertEquals(9, (int) list.get(1)); assertNull(list.get(2)); assertEquals(11, (int) list.get(3)); assertFalse(list.isEmpty()); assertEquals("[7, 9, null, 11]", list.toString()); assertTrue(list.contains(9)); assertFalse(list.contains(8)); list.addAll(Collections.nCopies(40, 1)); assertEquals(44, list.size()); assertEquals(1, (int) list.get(40)); int n = 0; for (Integer integer : list) { Util.discard(integer); ++n; } assertEquals(n, list.size()); int i = list.indexOf(null); assertEquals(2, i); list.set(2, 123); i = list.indexOf(null); assertEquals(-1, i); Collections.sort(list); list.remove((Integer) 7); Collections.sort(list); assertEquals(1, (int) list.get(3)); boolean b = list.removeAll(Arrays.asList(9)); assertTrue(b); b = list.removeAll(Arrays.asList(99)); assertFalse(b); list.add(12345); b = list.removeAll(Arrays.asList(12345)); assertTrue(b); list.add(12345); list.add(123); b = list.removeAll(Arrays.asList(12345)); assertTrue(b); assertEquals( 1000, new ChunkList<Integer>(Collections.nCopies(1000, 77)).size()); final ChunkList<String> list2 = new ChunkList<String>(); list2.listIterator(0).add("x"); assertEquals("[x]", list2.toString()); list2.add(0, "y"); assertEquals("[y, x]", list2.toString()); }