fun with collections

This commit is contained in:
Joel Dice
2007-07-21 21:47:29 -06:00
parent da17490206
commit ecd31a10a4
11 changed files with 566 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package java.util;
public class Vector<T> implements List<T> {
private final ArrayList<T> list;
public Vector(int capacity) {
list = new ArrayList(capacity);
}
public Vector() {
this(0);
}
public synchronized int size() {
return list.size();
}
public synchronized boolean add(T element) {
return list.add(element);
}
public void addElement(T element) {
add(element);
}
public synchronized T get(int index) {
return list.get(index);
}
public T elementAt(int index) {
return get(index);
}
public synchronized T remove(int index) {
return list.remove(index);
}
public synchronized boolean remove(T element) {
return list.remove(element);
}
public synchronized void clear() {
list.clear();
}
public Iterator<T> iterator() {
return new Collections.ArrayListIterator(this);
}
public Enumeration<T> elements() {
return new Collections.IteratorEnumeration(iterator());
}
}