merge Vec
authoradam <adam@megacz.com>
Sat, 30 Oct 2004 22:51:28 +0000 (22:51 +0000)
committeradam <adam@megacz.com>
Sat, 30 Oct 2004 22:51:28 +0000 (22:51 +0000)
darcs-hash:20041030225128-5007d-8cc86f38e7d37141164e12ccd3e5d90a31d56165.gz

src/org/ibex/util/Vec.java

index 6d1fbd5..f6a2453 100644 (file)
@@ -17,7 +17,7 @@ import java.io.*;
  *
  *  @see java.util.Vector
  */
-public final class Vec implements Serializable {
+public final class Vec implements Serializable, Cloneable {
     
     private Object[] store;
     private int size = 0;
@@ -25,7 +25,13 @@ public final class Vec implements Serializable {
     public Vec() { this(10); }
     public Vec(int i) { store = new Object[i]; }
     public Vec(int i, Object[] store) { size = i; this.store = store; }
-    
+    public Vec(Vec old) {
+        store = new Object[old.store.length];
+        System.arraycopy(old.store, 0, store, 0, old.store.length);
+        this.size = old.size;
+    }
+
+    public Object clone() { return new Vec(this); }
     private void grow() { grow(store.length * 2); }
     private void grow(int newsize) {
         Object[] newstore = new Object[newsize];