public class VectorSet<E>
extends java.util.Vector<E>
implements java.util.Set<E>
Constructor and Description |
---|
VectorSet()
Constructs an empty vector so that its internal data array has size
10 and its standard capacity increment is zero.
|
VectorSet(java.util.Collection<? extends E> c)
Constructs a vector containing the elements of the specified collection, in
the order they are returned by the collection's iterator.
|
VectorSet(int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its
capacity increment equal to zero.
|
VectorSet(int initialCapacity,
int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity
increment.
|
VectorSet(java.util.Set<? extends E> s)
Constructs a vector containing the elements of the specified set, in the
order they are returned by the set's iterator.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Appends the specified element to the end of this Vector if it is not
already present.
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this Vector if
it is not already present.
|
boolean |
addAll(java.util.Collection<? extends E> c)
Adds all of the elements in the specified collection to this set if they're
not already present.
|
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
Inserts all of the elements in in the specified Collection into this Vector
at the specified position if they're not already present.
|
void |
addElement(E obj)
Adds the specified component to the end of this vector if it is not already
present.
|
void |
insertElementAt(E obj,
int index)
Inserts the specified object as a component in this vector at the specified
index if it is not already present. |
E |
set(int index,
E element)
Replaces the element at the specified position in this Vector with the
specified element if it is not already present.
|
void |
setElementAt(E obj,
int index)
Sets the component at the specified
index of this vector to be
the specified object if it is not already present. |
capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, removeRange, replaceAll, retainAll, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
finalize, getClass, notify, notifyAll, wait, wait, wait
public VectorSet()
public VectorSet(java.util.Collection<? extends E> c)
c
- the collection whose elements are to be placed into this vector.public VectorSet(int initialCapacity)
initialCapacity
- the initial capacity of the vector.java.lang.IllegalArgumentException
- if the specified initial capacity is
negativepublic VectorSet(int initialCapacity, int capacityIncrement)
initialCapacity
- the initial capacity of the vector.capacityIncrement
- the amount by which the capacity is increased when
the vector overflows.java.lang.IllegalArgumentException
- if the specified initial capacity is
negativepublic VectorSet(java.util.Set<? extends E> s)
s
- the set whose elements are to be placed into this vector.public void add(int index, E element)
add
in interface java.util.List<E>
add
in class java.util.Vector<E>
index
- index at which the specified element is to be inserted.element
- element to be inserted.java.lang.ArrayIndexOutOfBoundsException
- index is out of range (index <
0 || index > size()).public boolean add(E o)
o
,
to this set if this set contains no element e
such that
(o==null ? e==null :
o.equals(e))
. If this set already contains the specified element,
the call leaves this set unchanged and returns false. In
combination with the restriction on constructors, this ensures that sets
never contain duplicate elements.
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in interface java.util.Set<E>
add
in class java.util.Vector<E>
o
- element to be added to this set.public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in interface java.util.Set<E>
addAll
in class java.util.Vector<E>
c
- collection whose elements are to be added to this set.add(Object)
public boolean addAll(int index, java.util.Collection<? extends E> c)
addAll
in interface java.util.List<E>
addAll
in class java.util.Vector<E>
index
- index at which to insert first element from the specified
collection.c
- elements to be inserted into this Vector.java.lang.ArrayIndexOutOfBoundsException
- index out of range (index < 0
|| index > size()).public void addElement(E obj)
addElement
in class java.util.Vector<E>
obj
- the component to be added.add(Object)
,
List
public void insertElementAt(E obj, int index)
index
if it is not already present. 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(Object, int) 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 java.util.Vector<E>
obj
- the component to insert.index
- where to insert the new component.java.lang.ArrayIndexOutOfBoundsException
- if the index was invalid.Vector.size()
,
add(int, Object)
,
List
public E set(int index, E element)
set
in interface java.util.List<E>
set
in class java.util.Vector<E>
index
- index of element to replace.element
- element to be stored at the specified position.java.lang.ArrayIndexOutOfBoundsException
- index out of range (index < 0
|| index >= size()).java.lang.IllegalArgumentException
- fromIndex > toIndex.public void setElementAt(E obj, int index)
index
of this vector to be
the specified object if it is not already present. 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 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 java.util.Vector<E>
obj
- what the component is to be set to.index
- the specified index.java.lang.ArrayIndexOutOfBoundsException
- if the index was invalid.Vector.size()
,
List
,
set(int, java.lang.Object)