1 16 package java.util; 17 18 23 public class Vector extends AbstractList implements List , RandomAccess , 24 Cloneable { 25 26 private transient ArrayList arrayList; 27 28 public Vector() { 29 arrayList = new ArrayList (); 30 } 31 32 public Vector(Collection c) { 33 arrayList = new ArrayList (); 34 addAll(c); 35 } 36 37 42 public Vector(int initialCapacity) { 43 arrayList = new ArrayList (initialCapacity); 44 } 45 46 public void add(int index, Object o) { 47 arrayList.add(index, o); 48 } 49 50 public boolean add(Object o) { 51 return arrayList.add(o); 52 } 53 54 public boolean addAll(Collection c) { 55 return arrayList.addAll(c); 56 } 57 58 public boolean addAll(int index, Collection c) { 59 return arrayList.addAll(index, c); 60 } 61 62 public void addElement(Object o) { 63 add(o); 64 } 65 66 public void clear() { 67 arrayList.clear(); 68 } 69 70 public Object clone() { 71 return new Vector (this); 72 } 73 74 public boolean contains(Object elem) { 75 return arrayList.contains(elem); 76 } 77 78 public void copyInto(Object [] objs) { 79 int i = -1; 80 int n = size(); 81 while (++i < n) { 82 objs[i] = get(i); 83 } 84 } 85 86 public Object elementAt(int index) { 87 return get(index); 88 } 89 90 public Object firstElement() { 91 return get(0); 92 } 93 94 public Object get(int index) { 95 return arrayList.get(index); 96 } 97 98 public int indexOf(Object elem) { 99 return arrayList.indexOf(elem); 100 } 101 102 public int indexOf(Object elem, int index) { 103 return arrayList.indexOf(elem, index); 104 } 105 106 public void insertElementAt(Object o, int index) { 107 add(index, o); 108 } 109 110 public boolean isEmpty() { 111 return (arrayList.size() == 0); 112 } 113 114 public Iterator iterator() { 115 return arrayList.iterator(); 116 } 117 118 public Object lastElement() { 119 if (isEmpty()) { 120 throw new IndexOutOfBoundsException ("last"); 121 } else { 122 return get(size() - 1); 123 } 124 } 125 126 public int lastIndexOf(Object o) { 127 return arrayList.lastIndexOf(o); 128 } 129 130 public int lastIndexOf(Object o, int index) { 131 return arrayList.lastIndexOf(o, index); 132 } 133 134 public Object remove(int index) { 135 return arrayList.remove(index); 136 } 137 138 public void removeAllElements() { 139 clear(); 140 } 141 142 public boolean removeElement(Object o) { 143 return remove(o); 144 } 145 146 public void removeElementAt(int index) { 147 remove(index); 148 } 149 150 public Object set(int index, Object elem) { 151 return arrayList.set(index, elem); 152 } 153 154 public void setElementAt(Object o, int index) { 155 set(index, o); 156 } 157 158 public void setSize(int size) { 159 arrayList.setSize(size); 160 } 161 162 public int size() { 163 return arrayList.size(); 164 } 165 166 public Object [] toArray() { 167 return arrayList.toArray(); 168 } 169 170 protected void removeRange(int fromIndex, int endIndex) { 171 arrayList.removeRange(fromIndex, endIndex); 172 } 173 } 174
| Popular Tags
|