public class Vector extends Object implements Collection, Cloneable, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected int |
capacityIncrement |
protected int |
elementCount |
protected Object[] |
elementData |
serialVersionUID| Constructor and Description |
|---|
Vector()
Constructs an empty vector.
|
Vector(int size)
Constructs an empty vector with a given initial size.
|
Vector(int initialCapacity,
int capacityIncrement) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
Object element) |
boolean |
add(Object element)
Add an element to the end of the Vector.
|
boolean |
addAll(Collection c)
Add the contents of a given collection to this collection.
|
boolean |
addAll(int index,
Collection c) |
void |
addElement(Object obj)
Add an element to the end of the Vector.
|
int |
capacity() |
void |
clear()
Clear the collection, such that a subsequent call to isEmpty() would
return true.
|
Object |
clone()
Creates a new Vector with the same contents as this one.
|
boolean |
contains(Object elem)
Test whether this collection contains a given object as one of its
elements.
|
boolean |
containsAll(Collection c)
Test whether this collection contains every element in a given collection.
|
void |
copyInto(Object[] destination) |
Object |
elementAt(int index) |
Enumeration |
elements()
Return an Enumeration over the elements in the Vector.
|
void |
ensureCapacity(int minimumCapacity) |
Object |
firstElement() |
Object |
get(int index)
Get the element at a particular index.
|
int |
indexOf(Object obj) |
int |
indexOf(Object elem,
int startIndex) |
void |
insertElementAt(Object obj,
int index) |
boolean |
isEmpty()
Test whether this collection is empty, that is, if size() == 0.
|
Iterator |
iterator()
Return an Iterator over the elements in the Vector.
|
Object |
lastElement() |
int |
lastIndexOf(Object obj) |
int |
lastIndexOf(Object elem,
int index) |
boolean |
remove(Object obj)
Remove a single occurrence of an object from this collection.
|
boolean |
removeAll(Collection c)
Remove all elements of a given collection from this collection.
|
void |
removeAllElements() |
boolean |
removeElement(Object obj) |
void |
removeElementAt(int index) |
boolean |
retainAll(Collection c)
Remove all elements of this collection that are not contained in a given
collection.
|
void |
setElementAt(Object obj,
int index) |
void |
setSize(int newSize) |
int |
size()
Get the number of elements in this collection.
|
Object[] |
toArray()
Copy the current contents of this collection into an array.
|
Object[] |
toArray(Object[] a)
Copy the current contents of this collection into an array.
|
String |
toString()
Return a String representation of this object.
|
void |
trimToSize() |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCodeprotected Object[] elementData
protected int elementCount
protected int capacityIncrement
public Vector()
public Vector(int size)
public Vector(int initialCapacity,
int capacityIncrement)
public Object clone()
public void insertElementAt(Object obj, int index)
public void addElement(Object obj)
obj - The object to add.public final int capacity()
public boolean contains(Object elem)
Collectioncontains in interface Collectionelem - the element to look for.o == null ? e == null : o.equals(e).public void copyInto(Object[] destination)
public Object elementAt(int index)
public void ensureCapacity(int minimumCapacity)
public Object firstElement()
public int indexOf(Object elem, int startIndex)
public int indexOf(Object obj)
public boolean isEmpty()
CollectionisEmpty in interface Collectionpublic Object lastElement()
public int lastIndexOf(Object elem, int index)
public int lastIndexOf(Object obj)
public void removeAllElements()
public boolean removeElement(Object obj)
public void removeElementAt(int index)
public void setElementAt(Object obj, int index)
public void add(int index,
Object element)
public void setSize(int newSize)
public int size()
Collectionsize in interface Collectionpublic String toString()
Objectpublic void trimToSize()
public Enumeration elements()
public Iterator iterator()
iterator in interface Collectionpublic boolean add(Object element)
add in interface Collectionelement - the element to add.public Object get(int index)
index - the index of the element.public boolean remove(Object obj)
Collectiono == null ? e == null
: o.equals(e).remove in interface Collectionobj - the object to remove.public void clear()
Collectionclear in interface Collectionpublic boolean addAll(Collection c)
CollectionaddAll in interface Collectionc - the collection to add.public boolean addAll(int index,
Collection c)
public boolean containsAll(Collection c)
CollectioncontainsAll in interface Collectionc - the collection to test for.public boolean removeAll(Collection c)
CollectionremoveAll in interface Collectionpublic boolean retainAll(Collection c)
CollectionretainAll in interface Collectionpublic Object[] toArray()
CollectiontoArray in interface Collectionpublic Object[] toArray(Object[] a)
CollectiontoArray in interface Collectiona - the array to copy this collection into.