public final class VectorSet<E> extends Vector<E>
This is not a general purpose class but has been written because
the protected members of DirectoryScanner
prohibited
later revisions from using a more efficient collection.
Methods are synchronized to keep Vector's contract.
capacityIncrement, elementCount, elementData
modCount
Constructor and Description |
---|
VectorSet() |
VectorSet(Collection<? extends E> c) |
VectorSet(int initialCapacity) |
VectorSet(int initialCapacity,
int capacityIncrement) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Appends the specified element to the end of this Vector.
|
void |
add(int index,
E o)
This implementation may not add the element at the given index
if it is already contained in the collection.
|
boolean |
addAll(Collection<? extends E> c)
Appends all of the elements in the specified Collection to the end of this Vector, in the order
that they are returned by the specified Collection's Iterator.
|
boolean |
addAll(int index,
Collection<? extends E> c)
This implementation may not add all elements at the given index
if any of them are already contained in the collection.
|
void |
addElement(E o)
Adds the specified component to the end of this vector, increasing its size by one.
|
void |
clear()
Removes all of the elements from this Vector.
|
Object |
clone()
Returns a clone of this vector.
|
boolean |
contains(Object o)
Returns
true if this vector contains the specified element. |
boolean |
containsAll(Collection<?> c)
Returns true if this Vector contains all of the elements in the specified Collection.
|
void |
insertElementAt(E o,
int index)
Inserts the specified object as a component in this vector at the specified
index . |
E |
remove(int index)
Removes the element at the specified position in this Vector.
|
boolean |
remove(Object o)
Removes the first occurrence of the specified element in this Vector If the Vector does not
contain the element, it is unchanged.
|
boolean |
removeAll(Collection<?> c)
Removes from this Vector all of its elements that are contained in the specified Collection.
|
void |
removeAllElements()
Removes all components from this vector and sets its size to zero.
|
boolean |
removeElement(Object o)
Removes the first (lowest-indexed) occurrence of the argument from this vector.
|
void |
removeElementAt(int index)
Deletes the component at the specified index.
|
void |
removeRange(int fromIndex,
int toIndex)
Removes from this list all of the elements whose index is between
fromIndex , inclusive,
and toIndex , exclusive. |
boolean |
retainAll(Collection<?> c)
Retains only the elements in this Vector that are contained in the specified Collection.
|
E |
set(int index,
E o)
Replaces the element at the specified position in this Vector with the specified element.
|
void |
setElementAt(E o,
int index)
Sets the component at the specified
index of this vector to be the specified object. |
capacity, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, setSize, size, subList, toArray, toArray, toString, trimToSize
public VectorSet()
public VectorSet(Collection<? extends E> c)
public VectorSet(int initialCapacity)
public VectorSet(int initialCapacity, int capacityIncrement)
public boolean add(E o)
Vector
add
in interface Collection<E>
add
in interface List<E>
add
in class Vector<E>
o
- element to be appended to this Vectortrue
(as specified by Collection.add(E)
)public void add(int index, E o)
public boolean addAll(Collection<? extends E> c)
Vector
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class Vector<E>
c
- elements to be inserted into this Vectortrue
if this Vector changed as a result of the callAbstractCollection.add(Object)
public boolean addAll(int index, Collection<? extends E> c)
public void addElement(E o)
Vector
This method is identical in functionality to the add(E)
method (which is
part of the List
interface).
addElement
in class Vector<E>
o
- the component to be addedpublic void clear()
Vector
public Object clone()
Vector
Vector
object.public boolean contains(Object o)
Vector
true
if this vector contains the specified element. More formally, returns
true
if and only if this vector contains at least one element e
such that
(o==null ? e==null : o.equals(e)).public boolean containsAll(Collection<?> c)
Vector
containsAll
in interface Collection<E>
containsAll
in interface List<E>
containsAll
in class Vector<E>
c
- a collection whose elements will be tested for containment in this VectorAbstractCollection.contains(Object)
public void insertElementAt(E o, int index)
Vector
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. (If the index is equal to the current size of the vector, the new
element is appended to the Vector.)
This method is identical in functionality to the add(int, E)
method
(which is part of the List
interface). Note that the add
method reverses the
order of the parameters, to more closely match array usage.
insertElementAt
in class Vector<E>
o
- the component to insertindex
- where to insert the new componentpublic E remove(int index)
Vector
public boolean remove(Object o)
Vector
(o==null ? get(i)==null : o.equals(get(i)))
(if such an element exists).public boolean removeAll(Collection<?> c)
Vector
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class Vector<E>
c
- a collection of elements to be removed from the VectorAbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
public void removeAllElements()
Vector
This method is identical in functionality to the Vector.clear()
method (which is part of the
List
interface).
removeAllElements
in class Vector<E>
public boolean removeElement(Object o)
Vector
This method is identical in functionality to the Vector.remove(Object)
method (which is part of
the List
interface).
removeElement
in class Vector<E>
o
- the component to be removedtrue
if the argument was a component of this vector; false
otherwise.public void removeElementAt(int index)
Vector
index
is shifted downward to have an index one smaller than the
value it had previously. The size of this vector is decreased by 1
.
The index must be a value greater than or equal to 0
and less than the current size of
the vector.
This method is identical in functionality to the Vector.remove(int)
method (which is part of
the List
interface). Note that the remove
method returns the old value that was
stored at the specified position.
removeElementAt
in class Vector<E>
index
- the index of the object to removepublic void removeRange(int fromIndex, int toIndex)
Vector
fromIndex
, inclusive,
and toIndex
, exclusive. Shifts any succeeding elements to the left (reduces their index).
This call shortens the list by (toIndex - fromIndex)
elements. (If
toIndex==fromIndex
, this operation has no effect.)removeRange
in class Vector<E>
fromIndex
- index of first element to be removedtoIndex
- index after last element to be removedpublic boolean retainAll(Collection<?> c)
Vector
retainAll
in interface Collection<E>
retainAll
in interface List<E>
retainAll
in class Vector<E>
c
- a collection of elements to be retained in this Vector (all other elements are removed)AbstractCollection.remove(Object)
,
AbstractCollection.contains(Object)
public E set(int index, E o)
Vector
public void setElementAt(E o, int index)
Vector
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.
This method is identical in functionality to the set(int, E)
method
(which is part of the List
interface). Note that the set
method reverses the
order of the parameters, to more closely match array usage. Note also that the set
method
returns the old value that was stored at the specified position.
setElementAt
in class Vector<E>
o
- what the component is to be set toindex
- the specified index