Make Vector a Cloneable

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2013-10-25 13:28:32 -05:00
parent 056c65947e
commit 6c46fe3f1a

View File

@ -10,7 +10,7 @@
package java.util;
public class Vector<T> extends AbstractList<T> implements java.io.Serializable {
public class Vector<T> extends AbstractList<T> implements java.io.Serializable, Cloneable {
private final ArrayList<T> list;
public Vector(int capacity) {
@ -126,5 +126,12 @@ public class Vector<T> extends AbstractList<T> implements java.io.Serializable {
public Enumeration<T> elements() {
return new Collections.IteratorEnumeration(iterator());
}
public synchronized Object clone() {
Vector copy = new Vector(size());
for (T t : this) {
copy.add(t);
}
return copy;
}
}