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, wait
equals, hashCode
protected 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)
Collection
contains
in interface Collection
elem
- 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()
Collection
isEmpty
in interface Collection
public 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()
Collection
size
in interface Collection
public String toString()
Object
public void trimToSize()
public Enumeration elements()
public Iterator iterator()
iterator
in interface Collection
public boolean add(Object element)
add
in interface Collection
element
- the element to add.public Object get(int index)
index
- the index of the element.public boolean remove(Object obj)
Collection
o == null ? e == null
: o.equals(e)
.remove
in interface Collection
obj
- the object to remove.public void clear()
Collection
clear
in interface Collection
public boolean addAll(Collection c)
Collection
addAll
in interface Collection
c
- the collection to add.public boolean addAll(int index, Collection c)
public boolean containsAll(Collection c)
Collection
containsAll
in interface Collection
c
- the collection to test for.public boolean removeAll(Collection c)
Collection
removeAll
in interface Collection
public boolean retainAll(Collection c)
Collection
retainAll
in interface Collection
public Object[] toArray()
Collection
toArray
in interface Collection
public Object[] toArray(Object[] a)
Collection
toArray
in interface Collection
a
- the array to copy this collection into.