Methods Summary |
---|
public synchronized void | appendElement(java.lang.Object o)
ensureCapacity(lastElement + 2);
data[++lastElement] = o;
|
public int | capacity()Returns the current capacity of the vector.
return data.length;
|
public java.lang.Object | clone()
Vector v = null;
try {
v = (Vector)super.clone();
}
catch (CloneNotSupportedException e) {
System.err.println("cannot clone Vector.super");
return null;
}
v.data = new Object[size()];
System.arraycopy(data, 0, v.data, 0, size());
return v;
|
public synchronized java.lang.Object | elementAt(int i)Returns the element at the specified index.
if (i >= data.length) {
throw new ArrayIndexOutOfBoundsException(i + " >= " + data.length);
}
if (i < 0) {
throw new ArrayIndexOutOfBoundsException(i + " < 0 ");
}
return data[i];
|
public synchronized java.util.Enumeration | elements()
return new VectorEnumerator(this);
|
public synchronized void | ensureCapacity(int minIndex)
if (minIndex + 1 > data.length) {
Object oldData[] = data;
int n = data.length * 2;
if (minIndex + 1 > n) {
n = minIndex + 1;
}
data = new Object[n];
System.arraycopy(oldData, 0, data, 0, oldData.length);
}
|
public synchronized boolean | removeElement(java.lang.Object o)
// find element
int i;
for (i = 0; i <= lastElement && data[i] != o; i++) {
;
}
if (i <= lastElement) { // if found it
data[i] = null; // kill ref for GC
int above = lastElement - i;
if (above > 0) {
System.arraycopy(data, i + 1, data, i, above);
}
lastElement--;
return true;
}
else {
return false;
}
|
public synchronized void | setElementAt(java.lang.Object obj, int i)
if (i >= data.length) {
throw new ArrayIndexOutOfBoundsException(i + " >= " + data.length);
}
data[i] = obj;
// track last element in the vector so we can append things
if (i > lastElement) {
lastElement = i;
}
|
public int | size()
return lastElement + 1;
|