mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
fun with collections
This commit is contained in:
54
classpath/java/util/Vector.java
Normal file
54
classpath/java/util/Vector.java
Normal 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());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user