com.isti.util
Class VectorSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector
              extended by com.isti.util.VectorSet
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.List, java.util.RandomAccess, java.util.Set

public class VectorSet
extends java.util.Vector
implements java.util.Set

Class VectorSet extends the "Vector" class to support the "Set" interface.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
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 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 s)
          Constructs a vector containing the elements of the specified set, in the order they are returned by the set's iterator.
 
Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this Vector if it is not already present.
 boolean add(java.lang.Object o)
          Appends the specified element to the end of this Vector if it is not already present.
 boolean addAll(java.util.Collection 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 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(java.lang.Object obj)
          Adds the specified component to the end of this vector if it is not already present.
 void insertElementAt(java.lang.Object obj, int index)
          Inserts the specified object as a component in this vector at the specified index if it is not already present.
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this Vector with the specified element if it is not already present.
 void setElementAt(java.lang.Object obj, int index)
          Sets the component at the specified index of this vector to be the specified object if it is not already present.
 
Methods inherited from class java.util.Vector
capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

VectorSet

public VectorSet()
Constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero.


VectorSet

public VectorSet(java.util.Collection c)
Constructs a vector containing the elements of the specified collection, in the order they are returned by the collection's iterator.

Parameters:
c - the collection whose elements are to be placed into this vector.

VectorSet

public VectorSet(int initialCapacity)
Constructs an empty vector with the specified initial capacity and with its capacity increment equal to zero.

Parameters:
initialCapacity - the initial capacity of the vector.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative

VectorSet

public VectorSet(int initialCapacity,
                 int capacityIncrement)
Constructs an empty vector with the specified initial capacity and capacity increment.

Parameters:
initialCapacity - the initial capacity of the vector.
capacityIncrement - the amount by which the capacity is increased when the vector overflows.
Throws:
java.lang.IllegalArgumentException - if the specified initial capacity is negative

VectorSet

public VectorSet(java.util.Set s)
Constructs a vector containing the elements of the specified set, in the order they are returned by the set's iterator.

Parameters:
s - the set whose elements are to be placed into this vector.
Method Detail

add

public void add(int index,
                java.lang.Object element)
Inserts the specified element at the specified position in this Vector if it is not already present. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Specified by:
add in interface java.util.List
Overrides:
add in class java.util.Vector
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.ArrayIndexOutOfBoundsException - index is out of range (index < 0 || index > size()).

add

public boolean add(java.lang.Object o)
Appends the specified element to the end of this Vector if it is not already present. More formally, adds the specified element, 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.

Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.List
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.Vector
Parameters:
o - element to be added to this set.
Returns:
true if this set did not already contain the specified element.

addAll

public boolean addAll(java.util.Collection c)
Adds all of the elements in the specified collection to this set if they're not already present. If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.

Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.List
Specified by:
addAll in interface java.util.Set
Overrides:
addAll in class java.util.Vector
Parameters:
c - collection whose elements are to be added to this set.
Returns:
true if this set changed as a result of the call.
See Also:
add(Object)

addAll

public boolean addAll(int index,
                      java.util.Collection c)
Inserts all of the elements in in the specified Collection into this Vector at the specified position if they're not already present. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the Vector in the order that they are returned by the specified Collection's iterator.

Specified by:
addAll in interface java.util.List
Overrides:
addAll in class java.util.Vector
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this Vector.
Returns:
true if this set changed as a result of the call.
Throws:
java.lang.ArrayIndexOutOfBoundsException - index out of range (index < 0 || index > size()).

addElement

public void addElement(java.lang.Object obj)
Adds the specified component to the end of this vector if it is not already present. This method is identical in functionality to the add(Object) method (which is part of the List interface).

Overrides:
addElement in class java.util.Vector
Parameters:
obj - the component to be added.
See Also:
add(Object), List

insertElementAt

public void insertElementAt(java.lang.Object obj,
                            int index)
Inserts the specified object as a component in this vector at the specified 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.

Overrides:
insertElementAt in class java.util.Vector
Parameters:
obj - the component to insert.
index - where to insert the new component.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
See Also:
Vector.size(), add(int, Object), List

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replaces the element at the specified position in this Vector with the specified element if it is not already present.

Specified by:
set in interface java.util.List
Overrides:
set in class java.util.Vector
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns:
the element previously at the specified position.
Throws:
java.lang.ArrayIndexOutOfBoundsException - index out of range (index < 0 || index >= size()).
java.lang.IllegalArgumentException - fromIndex > toIndex.

setElementAt

public void setElementAt(java.lang.Object obj,
                         int index)
Sets the component at the specified 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.

Overrides:
setElementAt in class java.util.Vector
Parameters:
obj - what the component is to be set to.
index - the specified index.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.
See Also:
Vector.size(), List, set(int, java.lang.Object)