@Test public void testPreAllocatedArray() { PreAllocatedArray<String> strings = new PreAllocatedArray<>(5); assertEquals(5, strings.length); strings = new PreAllocatedArray<>(3); assertEquals(3, strings.length); strings = new PreAllocatedArray<>(0); assertEquals(0, strings.length); }
public PreAllocatedArray(final int capacity) { length = capacity; internal = new ArrayList<>(capacity); for (int i = 0; i < capacity; i++) { internal.add(null); } }
PreAllocatedArray implements Iterable<T> { public PreAllocatedArray(final int capacity) { length = capacity; internal = new ArrayList<>(capacity); for (int i = 0; i < capacity; i++) { internal.add(null); } } }
PreAllocatedArray implements Iterable<T> { public PreAllocatedArray(final int capacity) { length = capacity; internal = new ArrayList<>(capacity); for (int i = 0; i < capacity; i++) { internal.add(null); } } PreAllocatedArray(final int capacity); }
PreAllocatedArray implements Iterable<T> { public PreAllocatedArray(final int capacity) { length = capacity; internal = new ArrayList<>(capacity); for (int i = 0; i < capacity; i++) { internal.add(null); } } PreAllocatedArray(final int capacity); T set(final int index, final T element); T get(final int index); @Override Iterator<T> iterator(); }
PreAllocatedArray implements Iterable<T> { public PreAllocatedArray(final int capacity) { length = capacity; internal = new ArrayList<>(capacity); for (int i = 0; i < capacity; i++) { internal.add(null); } } PreAllocatedArray(final int capacity); T set(final int index, final T element); T get(final int index); @Override Iterator<T> iterator(); final int length; }