コード例 #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));
 }