/** * Returns a shallow clone of this vector; the vector itself is cloned, but the element objects * aren't. */ public Object clone() { OVector clone = null; try { clone = (OVector) super.clone(); } catch (Exception e) { System.err.println("Error cloning " + getClass().getName() + ":"); e.printStackTrace(); System.exit(1); } clone.vector = (Object[]) vector.clone(); return clone; }
/** * Constructs a copy of a vector starting with capacity equal to that vector's size. * * @param v The vector to copy. */ public OVector(OVector v) { int N = v.size(); if (N == 0) vector = new Object[defaultCapacity]; else { vector = new Object[N]; size = N; System.arraycopy(v.vector, 0, vector, 0, N); } }