FastFullList implements Iterable<E> { private void removeTrail() { int last = this.size - 2; while (last >= 0 && this.arr[last] == this.blankElement) { last--; } this.size = last + 1; } @SuppressWarnings("unchecked")  FastFullList(final int capacity, final E blankElement); static FastFullList<F> newListWithCapacity(final int capacity); static FastFullListBuilder<F> builder(); static FastFullList<F> newList(final F... elements); int usedSize(); void set(final int index, final E element); E get(final int index); List<E> subList(final int fromIndex, final int toIndex); @Override Iterator<E> iterator();  }
@Test public final void testRemoveTrail() { final FastFullList<String> fl = FastFullList.<String>builder().build(); fl.set(10, "10"); fl.set(10, "20"); fl.set(5, "5"); fl.set(10, null); Assert.assertEquals(6, fl.usedSize()); }