예제 #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;
   }
 }
예제 #2
0
 public static void main(String[] args) {
   final int N = 100;
   StdDraw.setXscale(0, N);
   StdDraw.setYscale(0, N * N);
   StdDraw.setPenRadius(.01);
   for (int i = 1; i <= N; i++) {
     StdDraw.point(i, i);
     StdDraw.point(i, i * i);
     StdDraw.point(i, i * Math.log(i));
   }
 }
예제 #3
0
 public ResizingArray(int N) {
   this(N, Math.max(N, 4));
 }