Clonable vector with deep-copy semantics.

Enhancing container classes with deep-copy semantics
Steve Ball
Listing 2. Clonable vector with deep-copy semantics.

public class ClonableVector extends Vector implements Clonable {
  public ClonableVector() { super(); }
  public ClonableVector(Collection c) { super c; }
  public ClonableVector(int initialCapacity)
    { super(initialCapacity); }
  public ClonableVector(int initialCapacity, int capacityIncrement)
    { super(initialCapacity, capacityIncrement); }

  public Object clone() {
    ClonableVector clone = (ClonableVector) super.clone();
    for (int i = 0; i < clone.elementCount; ++i)
      clone.elementData[i] = GeneLab.clone(clone.elementData[i]);
    return clone;


Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events