Fix tabbing.... Please fix your editors so they do tabbing correctly!!! (Spaces...
[IRC.git] / Robust / src / ClassLibrary / Vector.java
index 1795dace2e4037faf1fce558aa28ef012c1f3732..df991ef8c6db7ef1ee038957fde8a3984657fe28 100644 (file)
@@ -9,12 +9,24 @@ public class Vector {
     array=new Object[10];
   }
 
-  public Vector( int size ) {
+  public Vector(int size) {
     capacityIncrement=0;
     this.size=0;
     array=new Object[size];
   }
 
+  //used for internal cloning
+  private Vector(int size, int capacityIncrement, Object[] array) {
+    this.size = size;
+    this.capacityIncrement = capacityIncrement;
+    this.array = new Object[array.length];
+    System.arraycopy(array, 0, this.array, 0, size);
+  }
+
+  public Vector clone() {
+    return new Vector(size,capacityIncrement, array);
+  }
+
   public boolean isEmpty() {
     return size==0;
   }
@@ -40,10 +52,14 @@ public class Vector {
     return indexOf(e)!=-1;
   }
 
-  public void remove(Object o) {
+  public boolean  remove(Object o) {
     int in=indexOf(o);
-    if (in!=-1)
+    if (in!=-1) {
       removeElementAt(in);
+      return true;
+    }
+
+    return false;
   }
 
   public Object elementAt(int index) {
@@ -64,7 +80,7 @@ public class Vector {
     }
   }
 
-  private ensureCapacity(int minCapacity) {
+  private void ensureCapacity(int minCapacity) {
     if (minCapacity>array.length) {
       int newsize;
       if (capacityIncrement<=0)
@@ -117,12 +133,12 @@ public class Vector {
       System.printString("Illegal Vector.removeElementAt\n");
       System.exit(-1);
     }
-    removeElement(array, index);
+    removeElement(array, index, size);
     size--;
     array[size]=null;
   }
 
-  public static native void removeElement(Object[] array, int index);
+  public static native void removeElement(Object[] array, int index, int size);
 
   public void removeAllElements() {
     int s = size;