00001 class Vector 00002 { 00003 int elementCount; 00004 java.lang.Object[] elementData; 00005 00006 public boolean contains (java.lang.Object elem) 00007 { 00008 return (this.indexOf(elem,0) >= 0); 00009 } 00010 00011 public synchronized void addElement (java.lang.Object obj) 00012 { 00013 this.elementCount = (this.elementCount + 1); 00014 this.elementData[this.elementCount] = obj; 00015 } 00016 00017 public int size () 00018 { 00019 return this.elementCount; 00020 } 00021 00022 public synchronized boolean removeElement (java.lang.Object obj) 00023 { 00024 int i = this.indexOf(obj); 00025 if (i >= 0) 00026 { 00027 this.removeElementAt(i); 00028 return true; 00029 } 00030 return false; 00031 } 00032 00033 public synchronized void removeAllElements () 00034 { 00035 for (int i = 0; i < this.elementCount; i = (i + 1)) 00036 { 00037 this.elementData[i] = null; 00038 } 00039 this.elementCount = 0; 00040 } 00041 00042 public synchronized java.lang.Object[] toArray () 00043 { 00044 java.lang.Object[] result = new java.lang.Object[this.elementCount]; 00045 this.arraycopy(this.elementData,0,result,0,this.elementCount); 00046 return result; 00047 } 00048 00049 public Vector(int n) 00050 { 00051 this.elementData = new java.lang.Object[n]; 00052 this.elementCount = 0; 00053 } 00054 00055 public synchronized int indexOf (java.lang.Object elem, int index) 00056 { 00057 if (elem == null) 00058 { 00059 for (int i = index; i < this.elementCount; i = (i + 1)) 00060 { 00061 if (this.elementData[i] == null) 00062 { 00063 return i; 00064 } 00065 } 00066 } else 00067 { 00068 for (int i = null; i$0 < this.elementCount; i$0 = (i$0 + 1)) 00069 { 00070 if (elem == this.elementData[i$0]) 00071 { 00072 return i$0; 00073 } 00074 } 00075 } 00076 return -1; 00077 } 00078 00079 public int indexOf (java.lang.Object elem) 00080 { 00081 return this.indexOf(elem,0); 00082 } 00083 00084 public synchronized void removeElementAt (int index) 00085 { 00086 if (index >= this.elementCount) 00087 { 00088 throw new java.lang.ArrayIndexOutOfBoundsException(java.lang.String.valueOf(index).concat(" >= ").concat(java.lang.String.valueOf(this.elementCount))); 00089 } else 00090 { 00091 if (index < 0) 00092 { 00093 throw new java.lang.ArrayIndexOutOfBoundsException(index); 00094 } 00095 } 00096 int j = ((this.elementCount - index) - 1); 00097 if (j > 0) 00098 { 00099 this.arraycopy(this.elementData,(index + 1),this.elementData,index,j); 00100 } 00101 this.elementCount = (this.elementCount - 1); 00102 this.elementData[this.elementCount] = null; 00103 } 00104 00105 private void arraycopy (java.lang.Object[] src, int src_position, java.lang.Object[] dest, int dest_position, int length) 00106 { 00107 for (int i = 0; i < length; i = (i + 1)) 00108 { 00109 dest[(dest_position + i)] = src[(src_position + i)]; 00110 } 00111 } 00112 }