Top Description Fields Constructors Methods
org.apache.tools.ant.util

public final Class VectorSet<E>

extends Vector<E>
Class Inheritance
Imports
java.util.Collection, .HashSet, .LinkedList, .Set, .Vector

Subclass of Vector that won't store duplicate entries and shows HashSet's constant time performance characteristics for the contains method.

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.

Since
Ant 1.8.0

Field Summary

Modifier and TypeField and Description
private static final long
private final HashSet<E>
Inherited from java.util.Vector:
capacityIncrementelementCountelementData

Constructor Summary

AccessConstructor and Description
public
public
VectorSet(int initialCapacity)

public
VectorSet(int initialCapacity, int capacityIncrement)

public
VectorSet(Collection<? extends E> c)

Method Summary

Modifier and TypeMethod and Description
public synchronized boolean
add(E
element to be appended to this Vector
o
)

Overrides java.util.Vector.add.

Implements java.util.List.add, java.util.Collection.add.

Appends the specified element to the end of this Vector.
public void
add(int
index at which the specified element is to be inserted
index
,
E
element to be inserted
o
)

Overrides java.util.Vector.add.

Implements java.util.List.add.

This implementation may not add the element at the given index if it is already contained in the collection.
public synchronized boolean
addAll(Collection<? extends E>
elements to be inserted into this Vector
c
)

Overrides java.util.Vector.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

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.
public synchronized boolean
addAll(int
index at which to insert the first element from the specified collection
index
,
Collection<? extends E>
elements to be inserted into this Vector
c
)

Overrides java.util.Vector.addAll.

Implements java.util.List.addAll.

This implementation may not add all elements at the given index if any of them are already contained in the collection.
public synchronized void
addElement(E
the component to be added
o
)

Overrides java.util.Vector.addElement.

Adds the specified component to the end of this vector, increasing its size by one.
public synchronized void
clear()

Overrides java.util.Vector.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Removes all of the elements from this Vector.
public Object
clone()

Overrides java.util.Vector.clone.

Returns a clone of this vector.
public synchronized boolean
contains(Object
element whose presence in this vector is to be tested
o
)

Overrides java.util.Vector.contains.

Implements java.util.List.contains, java.util.Collection.contains.

Returns true if this vector contains the specified element.
public synchronized boolean
containsAll(Collection<?>
a collection whose elements will be tested for containment in this Vector
c
)

Overrides java.util.Vector.containsAll.

Implements java.util.List.containsAll, java.util.Collection.containsAll.

Returns true if this Vector contains all of the elements in the specified Collection.
private synchronized void
doAdd(int index, E o)

private synchronized boolean
public void
insertElementAt(E
the component to insert
o
,
int
where to insert the new component
index
)

Overrides java.util.Vector.insertElementAt.

Inserts the specified object as a component in this vector at the specified index.
public synchronized E
remove(int
the index of the element to be removed
index
)

Overrides java.util.Vector.remove.

Implements java.util.List.remove.

Removes the element at the specified position in this Vector.
public boolean
remove(Object
element to be removed from this Vector, if present
o
)

Overrides java.util.Vector.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged.
public synchronized boolean
removeAll(Collection<?>
a collection of elements to be removed from the Vector
c
)

Overrides java.util.Vector.removeAll.

Implements java.util.List.removeAll, java.util.Collection.removeAll.

Removes from this Vector all of its elements that are contained in the specified Collection.
public synchronized void
removeAllElements()

Overrides java.util.Vector.removeAllElements.

Removes all components from this vector and sets its size to zero.
public boolean
removeElement(Object
the component to be removed
o
)

Overrides java.util.Vector.removeElement.

Removes the first (lowest-indexed) occurrence of the argument from this vector.
public synchronized void
removeElementAt(int
the index of the object to remove
index
)

Overrides java.util.Vector.removeElementAt.

Deletes the component at the specified index.
public synchronized void
removeRange(final int
index of first element to be removed
fromIndex
,
int
index after last element to be removed
toIndex
)

Overrides java.util.Vector.removeRange.

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.
public synchronized boolean
retainAll(Collection<?>
a collection of elements to be retained in this Vector (all other elements are removed)
c
)

Overrides java.util.Vector.retainAll.

Implements java.util.List.retainAll, java.util.Collection.retainAll.

Retains only the elements in this Vector that are contained in the specified Collection.
public synchronized E
set(int
index of the element to replace
index
,
E
element to be stored at the specified position
o
)

Overrides java.util.Vector.set.

Implements java.util.List.set.

Replaces the element at the specified position in this Vector with the specified element.
public void
setElementAt(E
what the component is to be set to
o
,
int
the specified index
index
)

Overrides java.util.Vector.setElementAt.

Sets the component at the specified index of this vector to be the specified object.
Inherited from java.util.Vector:
capacitycopyIntoelementAtelementsensureCapacityequalsfirstElementforEachgethashCodeindexOfindexOfisEmptyiteratorlastElementlastIndexOflastIndexOflistIteratorlistIteratorremoveIfreplaceAllsetSizesizesortspliteratorsubListtoArraytoArraytoStringtrimToSize

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.util.Vector.serialVersionUID.

setback to summary
private final HashSet<E> set

Constructor Detail

VectorSetback to summary
public VectorSet()
VectorSetback to summary
public VectorSet(int initialCapacity)
VectorSetback to summary
public VectorSet(int initialCapacity, int capacityIncrement)
VectorSetback to summary
public VectorSet(Collection<? extends E> c)

Method Detail

addback to summary
public synchronized boolean add(E o)

Overrides java.util.Vector.add.

Implements java.util.List.add, java.util.Collection.add.

Doc from java.util.Vector.add.

Appends the specified element to the end of this Vector.

Parameters
o:E

element to be appended to this Vector

Returns:boolean

true (as specified by Collection#add)

Annotations
@Override
addback to summary
public void add(int index, E o)

Overrides java.util.Vector.add.

Implements java.util.List.add.

This implementation may not add the element at the given index if it is already contained in the collection.

Parameters
index:int

Doc from java.util.Vector.add.

index at which the specified element is to be inserted

o:E

Doc from java.util.Vector.add.

element to be inserted

Annotations
@Override
addAllback to summary
public synchronized boolean addAll(Collection<? extends E> c)

Overrides java.util.Vector.addAll.

Implements java.util.List.addAll, java.util.Collection.addAll.

Doc from java.util.Vector.addAll.

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. The behavior of this operation is undefined if the specified Collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is this Vector, and this Vector is nonempty.)

Parameters
c:Collection<? extends E>

elements to be inserted into this Vector

Returns:boolean

true if this Vector changed as a result of the call

Annotations
@Override
addAllback to summary
public synchronized boolean addAll(int index, Collection<? extends E> c)

Overrides java.util.Vector.addAll.

Implements java.util.List.addAll.

This implementation may not add all elements at the given index if any of them are already contained in the collection.

Parameters
index:int

Doc from java.util.Vector.addAll.

index at which to insert the first element from the specified collection

c:Collection<? extends E>

Doc from java.util.Vector.addAll.

elements to be inserted into this Vector

Returns:boolean

Doc from java.util.Vector.addAll.

true if this Vector changed as a result of the call

Annotations
@Override
addElementback to summary
public synchronized void addElement(E o)

Overrides java.util.Vector.addElement.

Doc from java.util.Vector.addElement.

Adds the specified component to the end of this vector, increasing its size by one. The capacity of this vector is increased if its size becomes greater than its capacity.

This method is identical in functionality to the add(E) method (which is part of the List interface).

Parameters
o:E

the component to be added

Annotations
@Override
clearback to summary
public synchronized void clear()

Overrides java.util.Vector.clear.

Implements java.util.List.clear, java.util.Collection.clear.

Doc from java.util.Vector.clear.

Removes all of the elements from this Vector. The Vector will be empty after this call returns (unless it throws an exception).

Annotations
@Override
cloneback to summary
public Object clone()

Overrides java.util.Vector.clone.

Doc from java.util.Vector.clone.

Returns a clone of this vector. The copy will contain a reference to a clone of the internal data array, not a reference to the original internal data array of this Vector object.

Returns:Object

a clone of this vector

Annotations
@Override
containsback to summary
public synchronized boolean contains(Object o)

Overrides java.util.Vector.contains.

Implements java.util.List.contains, java.util.Collection.contains.

Doc from java.util.Vector.contains.

Returns 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 Objects.equals(o, e).

Parameters
o:Object

element whose presence in this vector is to be tested

Returns:boolean

true if this vector contains the specified element

Annotations
@Override
containsAllback to summary
public synchronized boolean containsAll(Collection<?> c)

Overrides java.util.Vector.containsAll.

Implements java.util.List.containsAll, java.util.Collection.containsAll.

Doc from java.util.Vector.containsAll.

Returns true if this Vector contains all of the elements in the specified Collection.

Parameters
c:Collection<?>

a collection whose elements will be tested for containment in this Vector

Returns:boolean

true if this Vector contains all of the elements in the specified collection

Annotations
@Override
doAddback to summary
private synchronized void doAdd(int index, E o)
doRemoveback to summary
private synchronized boolean doRemove(Object o)
insertElementAtback to summary
public void insertElementAt(E o, int index)

Overrides java.util.Vector.insertElementAt.

Doc from java.util.Vector.insertElementAt.

Inserts the specified object as a component in this vector at the specified 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.

Parameters
o:E

the component to insert

index:int

where to insert the new component

Annotations
@Override
removeback to summary
public synchronized E remove(int index)

Overrides java.util.Vector.remove.

Implements java.util.List.remove.

Doc from java.util.Vector.remove.

Removes the element at the specified position in this Vector. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the Vector.

Parameters
index:int

the index of the element to be removed

Returns:E

element that was removed

Annotations
@Override
removeback to summary
public boolean remove(Object o)

Overrides java.util.Vector.remove.

Implements java.util.List.remove, java.util.Collection.remove.

Doc from java.util.Vector.remove.

Removes the first occurrence of the specified element in this Vector If the Vector does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that Objects.equals(o, get(i)) (if such an element exists).

Parameters
o:Object

element to be removed from this Vector, if present

Returns:boolean

true if the Vector contained the specified element

Annotations
@Override
removeAllback to summary
public synchronized boolean removeAll(Collection<?> c)

Overrides java.util.Vector.removeAll.

Implements java.util.List.removeAll, java.util.Collection.removeAll.

Doc from java.util.Vector.removeAll.

Removes from this Vector all of its elements that are contained in the specified Collection.

Parameters
c:Collection<?>

a collection of elements to be removed from the Vector

Returns:boolean

true if this Vector changed as a result of the call

Annotations
@Override
removeAllElementsback to summary
public synchronized void removeAllElements()

Overrides java.util.Vector.removeAllElements.

Doc from java.util.Vector.removeAllElements.

Removes all components from this vector and sets its size to zero.

This method is identical in functionality to the clear method (which is part of the List interface).

Annotations
@Override
removeElementback to summary
public boolean removeElement(Object o)

Overrides java.util.Vector.removeElement.

Doc from java.util.Vector.removeElement.

Removes the first (lowest-indexed) occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously.

This method is identical in functionality to the remove(Object) method (which is part of the List interface).

Parameters
o:Object

the component to be removed

Returns:boolean

true if the argument was a component of this vector; false otherwise.

Annotations
@Override
removeElementAtback to summary
public synchronized void removeElementAt(int index)

Overrides java.util.Vector.removeElementAt.

Doc from java.util.Vector.removeElementAt.

Deletes the component at the specified index. Each component in this vector with an index greater or equal to the specified 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 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.

Parameters
index:int

the index of the object to remove

Annotations
@Override
removeRangeback to summary
public synchronized void removeRange(final int fromIndex, int toIndex)

Overrides java.util.Vector.removeRange.

Doc from java.util.Vector.removeRange.

Removes from this list all of the elements whose index is between 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.)

Parameters
fromIndex:int

Doc from java.util.AbstractList.removeRange.

index of first element to be removed

toIndex:int

Doc from java.util.AbstractList.removeRange.

index after last element to be removed

Annotations
@Override
retainAllback to summary
public synchronized boolean retainAll(Collection<?> c)

Overrides java.util.Vector.retainAll.

Implements java.util.List.retainAll, java.util.Collection.retainAll.

Doc from java.util.Vector.retainAll.

Retains only the elements in this Vector that are contained in the specified Collection. In other words, removes from this Vector all of its elements that are not contained in the specified Collection.

Parameters
c:Collection<?>

a collection of elements to be retained in this Vector (all other elements are removed)

Returns:boolean

true if this Vector changed as a result of the call

Annotations
@Override
setback to summary
public synchronized E set(int index, E o)

Overrides java.util.Vector.set.

Implements java.util.List.set.

Doc from java.util.Vector.set.

Replaces the element at the specified position in this Vector with the specified element.

Parameters
index:int

index of the element to replace

o:E

element to be stored at the specified position

Returns:E

the element previously at the specified position

Annotations
@Override
setElementAtback to summary
public void setElementAt(E o, int index)

Overrides java.util.Vector.setElementAt.

Doc from java.util.Vector.setElementAt.

Sets the component at the specified 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.

Parameters
o:E

what the component is to be set to

index:int

the specified index

Annotations
@Override