VectorOfDouble, VectorOfFloat, VectorOfLongpublic class Vector
extends java.lang.Object
Vector| Modifier and Type | Field | Description |
|---|---|---|
protected int |
capacityIncrement |
|
protected int |
elementCount |
|
protected java.lang.Object[] |
elementData |
| Constructor | Description |
|---|---|
Vector() |
Constructs an empty vector.
|
Vector(int initialCapacity) |
Constructs an empty vector with the specified initial capacity.
|
Vector(int initialCapacity,
int capacityIncrement) |
Constructs an empty vector with the specified initial capacity and
capacity increment.
|
Vector(java.lang.Object[] array) |
Constructs a vector from an array of objects.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addElement(java.lang.Object obj) |
Adds the specified component to the end of this vector,
increasing its size by one.
|
int |
capacity() |
Returns the current capacity of this vector.
|
java.lang.Object |
clone() |
|
boolean |
contains(java.lang.Object elem) |
Tests if the specified object is a component in this vector.
|
void |
copyInto(java.lang.Object[] anArray) |
Copies the components of this vector into the specified array.
|
java.lang.Object |
elementAt(int index) |
Returns the component at the specified index.
|
java.util.Enumeration |
elements() |
Returns an enumeration of the components of this vector.
|
void |
ensureCapacity(int minCapacity) |
Increases the capacity of this vector, if necessary, to ensure
that it can hold at least the number of components specified by
the minimum capacity argument.
|
java.lang.Object |
firstElement() |
Returns the first component of this vector.
|
int |
indexOf(java.lang.Object elem) |
Searches for the first occurrence of the given argument, testing
for equality using the
equals method. |
int |
indexOf(java.lang.Object elem,
int index) |
Searches for the first occurrence of the given argument, beginning
the search at
index, and testing for equality using
the equals method. |
void |
insertElementAt(java.lang.Object obj,
int index) |
Inserts the specified object as a component in this vector at the
specified
index. |
boolean |
isEmpty() |
Tests if this vector has no components.
|
java.lang.Object |
lastElement() |
Returns the last component of the vector.
|
int |
lastIndexOf(java.lang.Object elem) |
Returns the index of the last occurrence of the specified object in
this vector.
|
int |
lastIndexOf(java.lang.Object elem,
int index) |
Searches backwards for the specified object, starting from the
specified index, and returns an index to it.
|
void |
removeAllElements() |
Removes all components from this vector and sets its size to zero.
|
boolean |
removeElement(java.lang.Object obj) |
Removes the first occurrence of the argument from this vector.
|
void |
removeElementAt(int index) |
Deletes the component at the specified index.
|
void |
setElementAt(java.lang.Object obj,
int index) |
Sets the component at the specified
index of this
vector to be the specified object. |
void |
setSize(int newSize) |
Sets the size of this vector.
|
int |
size() |
Returns the number of components in this vector.
|
java.lang.String |
toString() |
Returns a string representation of this vector.
|
void |
trimToSize() |
Trims the capacity of this vector to be the vector's current
size.
|
protected java.lang.Object[] elementData
protected int elementCount
protected int capacityIncrement
public Vector(int initialCapacity,
int capacityIncrement)
initialCapacity - the initial capacity of the vector.capacityIncrement - the amount by which the capacity ispublic Vector(int initialCapacity)
initialCapacity - the initial capacity of the vector.public Vector()
public Vector(java.lang.Object[] array)
array - the array to copy into the vector.public void copyInto(java.lang.Object[] anArray)
anArray - the array into which the components get copied.public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacity.public void setSize(int newSize)
null items are added to the end of
the vector. If the new size is less than the current size, all
components at index newSize and greater are discarded.newSize - the new size of this vector.public int capacity()
public final int size()
public boolean isEmpty()
true if this vector has no components;
false otherwise.public java.util.Enumeration elements()
Enumerationpublic boolean contains(java.lang.Object elem)
elem - an object.true if the specified object is a component in
this vector; false otherwise.public int indexOf(java.lang.Object elem)
equals method.elem - an object.-1 if the object is not found.Object.equals(java.lang.Object)public int indexOf(java.lang.Object elem,
int index)
index, and testing for equality using
the equals method.elem - an object.index - the index to start searching from.index or later in the
vector; returns -1 if the object is not found.Object.equals(java.lang.Object)public int lastIndexOf(java.lang.Object elem)
elem - the desired component.-1 if the object is not found.public int lastIndexOf(java.lang.Object elem,
int index)
elem - the desired component.index - the index to start searching from.index in the vector;
-1 if the object is not found.public java.lang.Object elementAt(int index)
index - an index into this vector.java.lang.ArrayIndexOutOfBoundsException - if an invalid index was
given.public java.lang.Object firstElement()
java.util.NoSuchElementException - if this vector has no components.public java.lang.Object lastElement()
size() - 1.java.util.NoSuchElementException - if this vector is empty.public void setElementAt(java.lang.Object obj,
int index)
index of this
vector to be the specified object. The previous component at that
position is discarded.
The index must be a value greater than or equal to 0
and less than the current size of the vector.
obj - what the component is to be set to.index - the specified index.java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.Vector.size()public void removeElementAt(int index)
index is shifted downward to have an index one
smaller than the value it had previously.
The index must be a value greater than or equal to 0
and less than the current size of the vector.
index - the index of the object to remove.java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.Vector.size()public void insertElementAt(java.lang.Object obj,
int index)
index. Each component in this vector with
an index greater or equal to the specified index is
shifted upward to have an index one greater than the value it had
previously.
The index must be a value greater than or equal to 0
and less than or equal to the current size of the vector.
obj - the component to insert.index - where to insert the new component.java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.Vector.size()public void addElement(java.lang.Object obj)
obj - the component to be added.public boolean removeElement(java.lang.Object obj)
obj - the component to be removed.true if the argument was a component of this
vector; false otherwise.public void removeAllElements()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.Object clone()
clone in class java.lang.Object