12 public Vector( int size ) {
15 array=new Object[size];
18 public boolean isEmpty() {
27 public int indexOf(Object elem) {
28 return indexOf(elem, 0);
31 public int indexOf(Object elem, int index) {
32 for(int i=index; i<size; i++) {
33 if (elem.equals(array[i]))
39 public boolean contains(Object e) {
40 return indexOf(e)!=-1;
43 public void remove(Object o) {
49 public Object elementAt(int index) {
50 if (index<0 | index >=size) {
51 System.printString("Illegal Vector.elementAt\n");
58 public void setElementAt(Object obj, int index) {
62 System.printString("Illegal Vector.setElementAt\n");
67 private ensureCapacity(int minCapacity) {
68 if (minCapacity>array.length) {
70 if (capacityIncrement<=0)
71 newsize=array.length*2;
73 newsize=array.length+capacityIncrement;
74 if (newsize<minCapacity)
76 Object [] newarray=new Object[newsize];
77 for(int i=0; i<size; i++)
87 public Enumeration elements() {
88 System.printString("Vector.elements not implemented\n");
92 public void addElement(Object obj) {
93 if (size==array.length) {
94 ensureCapacity(size+1);
99 public void insertElementAt(Object obj, int index) {
100 if (index<0||index>size) {
101 System.printString("Illegal Vector.insertElementAt\n");
105 if (size==array.length) {
106 ensureCapacity(size+1);
109 for(int i=size-1; i>index; --i) {
110 array[i] = array[i-1];
115 public void removeElementAt(int index) {
116 if (index<0||index>=size) {
117 System.printString("Illegal Vector.removeElementAt\n");
120 removeElement(array, index, size);
125 public static native void removeElement(Object[] array, int index, int size);
127 public void removeAllElements() {
129 for(int i = 0; i<s; ++i ) {