FastFullList implements Iterable<E> { public void set(final int index, final E element) { final int lastIndex = this.size - 1; if (index < lastIndex) { this.arr[index] = element; } else if (index > lastIndex) { if (element != this.blankElement) { this.addMissingBlanks(index); this.arr[index] = element; } } else { if (element == this.blankElement) { this.removeTrail(); } else { this.arr[index] = element; } } } @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 testSet() { final FastFullList<String> fl = FastFullList.<String>builder().capacity(10).build(); Assert.assertEquals(0, fl.usedSize()); Assert.assertNull(fl.get(100)); for (int i = 0; i < 100; i++) { fl.set(i, "non blank"); Assert.assertEquals(i + 1, fl.usedSize()); } fl.set(100, null); Assert.assertEquals(100, fl.usedSize()); }