@SuppressWarnings("unchecked") public void ensureCapacity(int minCapacity) { opcount++; if (minCapacity > a.length) { int newCapacity = Math.max(minCapacity, a.length * 2); final T[] temp = (T[]) new Object[newCapacity]; for (int i = a.length - 1; i >= 0; i--) temp[i] = a[i]; a = temp; } }
public ResizingArray(int N) { this(N, Math.max(N, 4)); }