|
© 1998-2002 McGraw-Hill | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--structure.AbstractStructure
|
+--structure.AbstractList
|
+--structure.Vector
An implementation of extensible arrays, similar to that of java.util.Vector.
This vector class implements a basic extensible array. It does not implement
any of the additional features of the Sun class, including list-like operations.
Those operations are available in other implementors of List in this
package.
Example usage: To put a program's parameters into a Vector, we would use the following:
public static void main(String[] arguments)
{
Vector argVec = new Vector();
for (int i = 0; i < arguments.length; i++)
{
argVec.add(arguments[i]);
}
System.out.println(argVec);
}
| Field Summary | |
protected int |
capacityIncrement
The size of size increment, should the vector become full. |
protected static int |
defaultCapacity
The default size of the vector; may be overridden in the Vector(int) constructor. |
protected int |
elementCount
The actual number of elements logically stored within the vector. |
protected Object[] |
elementData
The data associated with the vector. |
protected Object |
initialValue
The initial value of any new elements that are appended to the vector. |
| Constructor Summary | |
Vector()
Construct an empty vector. |
|
Vector(Collection c)
|
|
Vector(int initialCapacity)
Construct an empty vector capable of storing initialCapacity
values before the vector must be extended. |
|
Vector(int initialCapacity,
int capacityIncr)
Construct a vector with initial capacity, and growth characteristic. |
|
Vector(int initialCapacity,
int capacityIncr,
Object initValue)
Construct a vector with initial size, growth rate and default value. |
|
Vector(Vector that)
|
|
| Method Summary | |
void |
add(int index,
Object obj)
Insert an element at a particular location. |
void |
add(Object obj)
Add an element to the high end of the array, possibly expanding vector. |
void |
addElement(Object o)
Add an element to the high end of the array, possibly expanding vector. |
int |
capacity()
Determine the capacity of the vector. |
void |
clear()
Remove all the values of the vector. |
Object |
clone()
Construct a shallow copy of the vector. |
boolean |
contains(Object elem)
Determine if a value appears in a vector. |
void |
copyInto(Object[] dest)
Copy the contents of the vector into an array. |
Object |
elementAt(int index)
Fetch the element at a particular index. |
void |
ensureCapacity(int minCapacity)
Ensure that the vector is capable of holding at least minCapacity values without expansion. |
Object |
firstElement()
Get access to the first element of the vector. |
Object |
get(int index)
Fetch the element at a particular index. |
int |
indexOf(Object elem)
Assuming the data is not in order, find the index of a value, or return -1 if not found. |
int |
indexOf(Object elem,
int index)
Assuming the data is not in order, find the index of a value or return -1 if the value is not found. |
void |
insertElementAt(Object obj,
int index)
Insert an element at a particular location. |
boolean |
isEmpty()
Determine if the Vector contains no values. |
Iterator |
iterator()
Construct a iterator over the elements of the vector. |
Object |
lastElement()
Fetch a reference to the last value in the vector. |
int |
lastIndexOf(Object obj)
Search for the last occurrence of a value within the vector. |
int |
lastIndexOf(Object obj,
int index)
Find the index of the last occurrence of the value in the vector before the indexth position. |
Object |
remove(int where)
Remove an element at a particular location. |
Object |
remove(Object element)
Remove an element, by value, from vector. |
void |
removeAllElements()
Remove all the elements of the vector. |
void |
removeElementAt(int where)
Remove an element at a particular location. |
Object |
set(int index,
Object obj)
Change the value stored at location index. |
void |
setElementAt(Object obj,
int index)
Change the value stored at location index. |
void |
setSize(int newSize)
Explicitly set the size of the array. |
int |
size()
Determine the number of elements in the vector. |
String |
toString()
Determine a string representation for the vector. |
void |
trimToSize()
Trim the vector to exactly the correct size. |
| Methods inherited from class structure.AbstractList |
addFirst, addLast, get, getFirst, getLast, remove, removeFirst, removeLast |
| Methods inherited from class structure.AbstractStructure |
elements, hashCode, values |
| Methods inherited from class java.lang.Object |
|
| Methods inherited from interface structure.Structure |
elements, values |
| Field Detail |
protected Object[] elementData
protected int elementCount
protected int capacityIncrement
protected Object initialValue
protected static final int defaultCapacity
Vector(int) constructor.| Constructor Detail |
public Vector()
public Vector(int initialCapacity)
initialCapacity
values before the vector must be extended.initialCapacity - The size of vector before reallocation is necessary
public Vector(int initialCapacity,
int capacityIncr)
initialCapacity - The initial number of slots in vector.capacityIncr - The size of growth of vector.capacityIncrement
public Vector(int initialCapacity,
int capacityIncr,
Object initValue)
initialCapacity - The initial number of slots in vector.capacityIncr - The size of the increment when vector grows.initValue - The initial value stored in vector elements.public Vector(Vector that)
public Vector(Collection c)
| Method Detail |
public void ensureCapacity(int minCapacity)
minCapacity - The minimum size of array before expansion.public void add(Object obj)
add in class AbstractListobj - The object to be added to the end of the vector.public void addElement(Object o)
obj - The object to be added to the end of the vector.public Object remove(Object element)
element - the element to be removed.public int capacity()
public Object clone()
clone in class Objectpublic boolean contains(Object elem)
contains in class AbstractListelem - The value sought.public void copyInto(Object[] dest)
dest - An array of size at least size().public Object elementAt(int index)
index - The index of the value sought.public Object get(int index)
index - The index of the value sought.public Iterator iterator()
public Object firstElement()
public int indexOf(Object elem)
elem - The value sought in vector.
public int indexOf(Object elem,
int index)
elem - The value sought.index - The first location considered.
public void insertElementAt(Object obj,
int index)
obj - The value to be inserted.index - The location of the new value.
public void add(int index,
Object obj)
obj - the value to be inserted.index - the location of the new value.public boolean isEmpty()
isEmpty in class AbstractListpublic Object lastElement()
public int lastIndexOf(Object obj)
obj - The value sought.
public int lastIndexOf(Object obj,
int index)
obj - The value sought.index - The last acceptable index.public void clear()
public void removeAllElements()
clear()public void removeElementAt(int where)
where - The location of the element to be removed.public Object remove(int where)
where - The location of the element to be removed.
public void setElementAt(Object obj,
int index)
obj - The new value to be stored.index - The index of the new value.
public Object set(int index,
Object obj)
obj - The new value to be stored.index - The index of the new value.public void setSize(int newSize)
newSize - The ultimate size of the vector.public int size()
public void trimToSize()
public String toString()
toString in class Object
|
© 1998-2002 McGraw-Hill | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||