DthingApi
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
java.util.Vector< E > Class Template Reference
Inheritance diagram for java.util.Vector< E >:
java.util.AbstractList< E > java.util.List< E > java.util.RandomAccess java.io.Serializable java.util.AbstractCollection< E > java.util.List< E > java.util.Collection< E > java.util.Collection< E > java.util.Collection< E >

Public Member Functions

 Vector ()
 
 Vector (int capacity)
 
 Vector (int capacity, int capacityIncrement)
 
 Vector (Collection<? extends E > collection)
 
void add (int location, E object)
 
synchronized boolean add (E object)
 
synchronized boolean addAll (int location, Collection<? extends E > collection)
 
synchronized boolean addAll (Collection<? extends E > collection)
 
synchronized void addElement (E object)
 
synchronized int capacity ()
 
void clear ()
 
synchronized Object clone ()
 
boolean contains (Object object)
 
synchronized boolean containsAll (Collection<?> collection)
 
synchronized void copyInto (Object[] elements)
 
synchronized E elementAt (int location)
 
Enumeration< E > elements ()
 
synchronized void ensureCapacity (int minimumCapacity)
 
synchronized boolean equals (Object object)
 
synchronized E firstElement ()
 
get (int location)
 
synchronized int hashCode ()
 
int indexOf (Object object)
 
synchronized int indexOf (Object object, int location)
 
synchronized void insertElementAt (E object, int location)
 
synchronized boolean isEmpty ()
 
synchronized E lastElement ()
 
synchronized int lastIndexOf (Object object)
 
synchronized int lastIndexOf (Object object, int location)
 
synchronized E remove (int location)
 
boolean remove (Object object)
 
synchronized boolean removeAll (Collection<?> collection)
 
synchronized void removeAllElements ()
 
synchronized boolean removeElement (Object object)
 
synchronized void removeElementAt (int location)
 
synchronized boolean retainAll (Collection<?> collection)
 
synchronized E set (int location, E object)
 
synchronized void setElementAt (E object, int location)
 
synchronized void setSize (int length)
 
synchronized int size ()
 
synchronized List< E > subList (int start, int end)
 
synchronized Object [] toArray ()
 
synchronized String toString ()
 
synchronized void trimToSize ()
 
- Public Member Functions inherited from java.util.AbstractList< E >
void add (int location, E object)
 
boolean add (E object)
 
boolean addAll (int location, Collection<? extends E > collection)
 
void clear ()
 
boolean equals (Object object)
 
abstract E get (int location)
 
int hashCode ()
 
int indexOf (Object object)
 
Iterator< E > iterator ()
 
int lastIndexOf (Object object)
 
ListIterator< E > listIterator ()
 
ListIterator< E > listIterator (int location)
 
remove (int location)
 
set (int location, E object)
 
List< E > subList (int start, int end)
 
- Public Member Functions inherited from java.util.AbstractCollection< E >
boolean add (E object)
 
boolean addAll (Collection<? extends E > collection)
 
void clear ()
 
boolean contains (Object object)
 
boolean containsAll (Collection<?> collection)
 
boolean isEmpty ()
 
abstract Iterator< E > iterator ()
 
boolean remove (Object object)
 
boolean removeAll (Collection<?> collection)
 
boolean retainAll (Collection<?> collection)
 
abstract int size ()
 
Object [] toArray ()
 
String toString ()
 

Protected Member Functions

void removeRange (int start, int end)
 
- Protected Member Functions inherited from java.util.AbstractList< E >
 AbstractList ()
 
void removeRange (int start, int end)
 
- Protected Member Functions inherited from java.util.AbstractCollection< E >
 AbstractCollection ()
 

Protected Attributes

int elementCount
 
Object [] elementData
 
int capacityIncrement
 
- Protected Attributes inherited from java.util.AbstractList< E >
transient int modCount
 

Detailed Description

Vector is an implementation of List, backed by an array and synchronized. All optional operations including adding, removing, and replacing elements are supported.

All elements are permitted, including null.

This class is equivalent to ArrayList with synchronized operations. This has a performance cost, and the synchronization is not necessarily meaningful to your application: synchronizing each call to

get

, for example, is not equivalent to synchronizing on the list and iterating over it (which is probably what you intended). If you do need very highly concurrent access, you should also consider java.util.concurrent.CopyOnWriteArrayList.

Parameters
<E>The element type of this list.

Constructor & Destructor Documentation

◆ Vector() [1/4]

java.util.Vector< E >.Vector ( )
inline

Constructs a new vector using the default capacity.

◆ Vector() [2/4]

java.util.Vector< E >.Vector ( int  capacity)
inline

Constructs a new vector using the specified capacity.

Parameters
capacitythe initial capacity of the new vector.
Exceptions
IllegalArgumentExceptionif is negative.

◆ Vector() [3/4]

java.util.Vector< E >.Vector ( int  capacity,
int  capacityIncrement 
)
inline

Constructs a new vector using the specified capacity and capacity increment.

Parameters
capacitythe initial capacity of the new vector.
capacityIncrementthe amount to increase the capacity when this vector is full.
Exceptions
IllegalArgumentExceptionif is negative.

◆ Vector() [4/4]

java.util.Vector< E >.Vector ( Collection<? extends E >  collection)
inline

Constructs a new instance of

containing the elements in

collection

. The order of the elements in the new

is dependent on the iteration order of the seed collection.

Parameters
collectionthe collection of elements to add.

Member Function Documentation

◆ add() [1/2]

void java.util.Vector< E >.add ( int  location,
object 
)
inline

Adds the specified object into this vector at the specified location. The object is inserted before any element with the same or a higher index increasing their index by 1. If the location is equal to the size of this vector, the object is added at the end.

Parameters
locationthe index at which to insert the element.
objectthe object to insert in this vector.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location > size()
.
See also
addElement
size

Implements java.util.List< E >.

◆ add() [2/2]

synchronized boolean java.util.Vector< E >.add ( object)
inline

Adds the specified object at the end of this vector.

Parameters
objectthe object to add to the vector.
Returns
true

Implements java.util.List< E >.

◆ addAll() [1/2]

synchronized boolean java.util.Vector< E >.addAll ( int  location,
Collection<? extends E >  collection 
)
inline

Inserts the objects in the specified collection at the specified location in this vector. The objects are inserted in the order in which they are returned from the Collection iterator. The elements with an index equal or higher than

location

have their index increased by the size of the added collection.

Parameters
locationthe location to insert the objects.
collectionthe collection of objects.
Returns
true
if this vector is modified,
false
otherwise.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0
or
location > size()
.

Implements java.util.List< E >.

◆ addAll() [2/2]

synchronized boolean java.util.Vector< E >.addAll ( Collection<? extends E >  collection)
inline

Adds the objects in the specified collection to the end of this vector.

Parameters
collectionthe collection of objects.
Returns
true
if this vector is modified,
false
otherwise.

Implements java.util.List< E >.

◆ addElement()

synchronized void java.util.Vector< E >.addElement ( object)
inline

Adds the specified object at the end of this vector.

Parameters
objectthe object to add to the vector.

◆ capacity()

synchronized int java.util.Vector< E >.capacity ( )
inline

Returns the number of elements this vector can hold without growing.

Returns
the capacity of this vector.
See also
ensureCapacity
size

◆ clear()

void java.util.Vector< E >.clear ( )
inline

Removes all elements from this vector, leaving it empty.

See also
isEmpty
size

Implements java.util.List< E >.

◆ clone()

synchronized Object java.util.Vector< E >.clone ( )
inline

Returns a new vector with the same elements, size, capacity and capacity increment as this vector.

Returns
a shallow copy of this vector.
See also
java.lang.Cloneable

◆ contains()

boolean java.util.Vector< E >.contains ( Object  object)
inline

Searches this vector for the specified object.

Parameters
objectthe object to look for in this vector.
Returns
true
if object is an element of this vector,
false
otherwise.
See also
indexOf(Object)
indexOf(Object, int)
java.lang.Object::equals

Implements java.util.List< E >.

◆ containsAll()

synchronized boolean java.util.Vector< E >.containsAll ( Collection<?>  collection)
inline

Searches this vector for all objects in the specified collection.

Parameters
collectionthe collection of objects.
Returns
true
if all objects in the specified collection are elements of this vector,
false
otherwise.

Implements java.util.List< E >.

◆ copyInto()

synchronized void java.util.Vector< E >.copyInto ( Object []  elements)
inline

Attempts to copy elements contained by this

into the corresponding elements of the supplied

Object

array.

Parameters
elementsthe
Object
array into which the elements of this vector are copied.
Exceptions
IndexOutOfBoundsExceptionif is not big enough.
See also
clone

◆ elementAt()

synchronized E java.util.Vector< E >.elementAt ( int  location)
inline

Returns the element at the specified location in this vector.

Parameters
locationthe index of the element to return in this vector.
Returns
the element at the specified location.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location >= size()
.
See also
size

◆ elements()

Enumeration<E> java.util.Vector< E >.elements ( )
inline

Returns an enumeration on the elements of this vector. The results of the enumeration may be affected if the contents of this vector is modified.

Returns
an enumeration of the elements of this vector.
See also
elementAt
Enumeration

◆ ensureCapacity()

synchronized void java.util.Vector< E >.ensureCapacity ( int  minimumCapacity)
inline

Ensures that this vector can hold the specified number of elements without growing.

Parameters
minimumCapacitythe minimum number of elements that this vector will hold before growing.
See also
capacity

◆ equals()

synchronized boolean java.util.Vector< E >.equals ( Object  object)
inline

Compares the specified object to this vector and returns if they are equal. The object must be a List which contains the same objects in the same order.

Parameters
objectthe object to compare with this object
Returns
true
if the specified object is equal to this vector,
false
otherwise.
See also
hashCode

Implements java.util.List< E >.

◆ firstElement()

synchronized E java.util.Vector< E >.firstElement ( )
inline

Returns the first element in this vector.

Returns
the element at the first position.
Exceptions
NoSuchElementExceptionif this vector is empty.
See also
elementAt
lastElement
size

◆ get()

E java.util.Vector< E >.get ( int  location)
inline

Returns the element at the specified location in this vector.

Parameters
locationthe index of the element to return in this vector.
Returns
the element at the specified location.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location >= size()
.
See also
size

Implements java.util.List< E >.

◆ hashCode()

synchronized int java.util.Vector< E >.hashCode ( )
inline

Returns an integer hash code for the receiver. Objects which are equal return the same value for this method.

Returns
the receiver's hash.
See also
equals

Implements java.util.List< E >.

◆ indexOf() [1/2]

int java.util.Vector< E >.indexOf ( Object  object)
inline

Searches in this vector for the index of the specified object. The search for the object starts at the beginning and moves towards the end of this vector.

Parameters
objectthe object to find in this vector.
Returns
the index in this vector of the specified element, -1 if the element isn't found.
See also
contains
lastIndexOf(Object)
lastIndexOf(Object, int)

Implements java.util.List< E >.

◆ indexOf() [2/2]

synchronized int java.util.Vector< E >.indexOf ( Object  object,
int  location 
)
inline

Searches in this vector for the index of the specified object. The search for the object starts at the specified location and moves towards the end of this vector.

Parameters
objectthe object to find in this vector.
locationthe index at which to start searching.
Returns
the index in this vector of the specified element, -1 if the element isn't found.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0
.
See also
contains
lastIndexOf(Object)
lastIndexOf(Object, int)

◆ insertElementAt()

synchronized void java.util.Vector< E >.insertElementAt ( object,
int  location 
)
inline

Inserts the specified object into this vector at the specified location. This object is inserted before any previous element at the specified location. All elements with an index equal or greater than

location

have their index increased by 1. If the location is equal to the size of this vector, the object is added at the end.

Parameters
objectthe object to insert in this vector.
locationthe index at which to insert the element.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location > size()
.
See also
addElement
size

◆ isEmpty()

synchronized boolean java.util.Vector< E >.isEmpty ( )
inline

Returns if this vector has no elements, a size of zero.

Returns
true
if this vector has no elements,
false
otherwise.
See also
size

Implements java.util.List< E >.

◆ lastElement()

synchronized E java.util.Vector< E >.lastElement ( )
inline

Returns the last element in this vector.

Returns
the element at the last position.
Exceptions
NoSuchElementExceptionif this vector is empty.
See also
elementAt
firstElement
size

◆ lastIndexOf() [1/2]

synchronized int java.util.Vector< E >.lastIndexOf ( Object  object)
inline

Searches in this vector for the index of the specified object. The search for the object starts at the end and moves towards the start of this vector.

Parameters
objectthe object to find in this vector.
Returns
the index in this vector of the specified element, -1 if the element isn't found.
See also
contains
indexOf(Object)
indexOf(Object, int)

Implements java.util.List< E >.

◆ lastIndexOf() [2/2]

synchronized int java.util.Vector< E >.lastIndexOf ( Object  object,
int  location 
)
inline

Searches in this vector for the index of the specified object. The search for the object starts at the specified location and moves towards the start of this vector.

Parameters
objectthe object to find in this vector.
locationthe index at which to start searching.
Returns
the index in this vector of the specified element, -1 if the element isn't found.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location >= size()
.
See also
contains
indexOf(Object)
indexOf(Object, int)

◆ remove() [1/2]

synchronized E java.util.Vector< E >.remove ( int  location)
inline

Removes the object at the specified location from this vector. All elements with an index bigger than

location

have their index decreased by 1.

Parameters
locationthe index of the object to remove.
Returns
the removed object.
Exceptions
IndexOutOfBoundsExceptionif
location < 0 || location >= size()
.

Implements java.util.List< E >.

◆ remove() [2/2]

boolean java.util.Vector< E >.remove ( Object  object)
inline

Removes the first occurrence, starting at the beginning and moving towards the end, of the specified object from this vector. All elements with an index bigger than the element that gets removed have their index decreased by 1.

Parameters
objectthe object to remove from this vector.
Returns
true
if the specified object was found,
false
otherwise.
See also
removeAllElements
removeElementAt
size

Implements java.util.List< E >.

◆ removeAll()

synchronized boolean java.util.Vector< E >.removeAll ( Collection<?>  collection)
inline

Removes all occurrences in this vector of each object in the specified Collection.

Parameters
collectionthe collection of objects to remove.
Returns
true
if this vector is modified,
false
otherwise.
See also
remove(Object)
contains(Object)

Implements java.util.List< E >.

◆ removeAllElements()

synchronized void java.util.Vector< E >.removeAllElements ( )
inline

Removes all elements from this vector, leaving the size zero and the capacity unchanged.

See also
isEmpty
size

◆ removeElement()

synchronized boolean java.util.Vector< E >.removeElement ( Object  object)
inline

Removes the first occurrence, starting at the beginning and moving towards the end, of the specified object from this vector. All elements with an index bigger than the element that gets removed have their index decreased by 1.

Parameters
objectthe object to remove from this vector.
Returns
true
if the specified object was found,
false
otherwise.
See also
removeAllElements
removeElementAt
size

◆ removeElementAt()

synchronized void java.util.Vector< E >.removeElementAt ( int  location)
inline

Removes the element found at index position

location

from this

. All elements with an index bigger than

location

have their index decreased by 1.

Parameters
locationthe index of the element to remove.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location >= size()
.
See also
removeElement
removeAllElements
size

◆ removeRange()

void java.util.Vector< E >.removeRange ( int  start,
int  end 
)
inlineprotected

Removes the objects in the specified range from the start to the, but not including, end index. All elements with an index bigger than or equal to

end

have their index decreased by

end - start

.

Parameters
startthe index at which to start removing.
endthe index one past the end of the range to remove.
Exceptions
IndexOutOfBoundsExceptionif
start < 0, start > end
or
end > size()
.

◆ retainAll()

synchronized boolean java.util.Vector< E >.retainAll ( Collection<?>  collection)
inline

Removes all objects from this vector that are not contained in the specified collection.

Parameters
collectionthe collection of objects to retain.
Returns
true
if this vector is modified,
false
otherwise.
See also
remove(Object)

Implements java.util.List< E >.

◆ set()

synchronized E java.util.Vector< E >.set ( int  location,
object 
)
inline

Replaces the element at the specified location in this vector with the specified object.

Parameters
locationthe index at which to put the specified object.
objectthe object to add to this vector.
Returns
the previous element at the location.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location >= size()
.
See also
size

Implements java.util.List< E >.

◆ setElementAt()

synchronized void java.util.Vector< E >.setElementAt ( object,
int  location 
)
inline

Replaces the element at the specified location in this vector with the specified object.

Parameters
objectthe object to add to this vector.
locationthe index at which to put the specified object.
Exceptions
ArrayIndexOutOfBoundsExceptionif
location < 0 || location >= size()
.
See also
size

◆ setSize()

synchronized void java.util.Vector< E >.setSize ( int  length)
inline

Sets the size of this vector to the specified size. If there are more than length elements in this vector, the elements at end are lost. If there are less than length elements in the vector, the additional elements contain null.

Parameters
lengththe new size of this vector.
See also
size

◆ size()

synchronized int java.util.Vector< E >.size ( )
inline

Returns the number of elements in this vector.

Returns
the number of elements in this vector.
See also
elementCount
lastElement

Implements java.util.List< E >.

◆ subList()

synchronized List<E> java.util.Vector< E >.subList ( int  start,
int  end 
)
inline

Returns a List of the specified portion of this vector from the start index to one less than the end index. The returned List is backed by this vector so changes to one are reflected by the other.

Parameters
startthe index at which to start the sublist.
endthe index one past the end of the sublist.
Returns
a List of a portion of this vector.
Exceptions
IndexOutOfBoundsExceptionif
start < 0
or
end > size()
.
IllegalArgumentExceptionif
start > end
.

Implements java.util.List< E >.

◆ toArray()

synchronized Object [] java.util.Vector< E >.toArray ( )
inline

Returns a new array containing all elements contained in this vector.

Returns
an array of the elements from this vector.

Implements java.util.List< E >.

◆ toString()

synchronized String java.util.Vector< E >.toString ( )
inline

Returns the string representation of this vector.

Returns
the string representation of this vector.
See also
elements

◆ trimToSize()

synchronized void java.util.Vector< E >.trimToSize ( )
inline

Sets the capacity of this vector to be the same as the size.

See also
capacity
ensureCapacity
size

Member Data Documentation

◆ capacityIncrement

int java.util.Vector< E >.capacityIncrement
protected

How many elements should be added to the vector when it is detected that it needs to grow to accommodate extra entries. If this value is zero or negative the size will be doubled if an increase is needed.

◆ elementCount

int java.util.Vector< E >.elementCount
protected

The number of elements or the size of the vector.

◆ elementData

Object [] java.util.Vector< E >.elementData
protected

The elements of the vector.


The documentation for this class was generated from the following file: