Clonable vector with deep-copy semantics.
- By Steve Ball
- September 12, 2000
EFFECTIVE JAVAEnhancing 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;
}
}