Exemplo n.º 1
0
 @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;
   }
 }
Exemplo n.º 2
0
 public ResizingArray(int N) {
   this(N, Math.max(N, 4));
 }