net.cscott.sinjdoc.parser
public class UniqueVector<E> extends AbstractList<E> implements Set<E>, Cloneable
Conforms to the JDK 1.2 Collections API.
Version: $Id: UniqueVector.java,v 1.2 2003/07/31 23:05:26 cananian Exp $
See Also: java.util.Vector java.util.Hashtable
Constructor Summary | |
---|---|
UniqueVector() Constructs an empty UniqueVector. | |
UniqueVector(int initialCapacity) Constructs an empty UniqueVector with the specified initial capacity. | |
UniqueVector(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. |
Method Summary | |
---|---|
void | add(int index, E element)
Inserts the specified element at the specified position in this list.
|
boolean | add(E obj)
Adds the specified component to the end of this vector, increasing
its size by one, if it doesn't already exist in the vector.
|
void | addElement(E obj)
Adds the specified component to the end of this vector, increasing
its size by one, if it doesn't already exist in the vector.
|
int | capacity()
Returns the current capacity of this vector. |
void | clear() Removes all of the elements from this collection. |
UniqueVector<E> | clone()
Returns a clone of this vector. |
boolean | contains(Object elem)
Tests if the specified object is a component in this vector. |
void | copyInto(Object[] anArray)
Copies the components of this vector into the specified array.
|
E | elementAt(int index)
Returns the component at the specified index. |
void | ensureCapacity(int minCapacity)
Increases the capacity of this vector, if necessary, to ensure that
it can hold at least the number of components specified by the minimum
capacity argument. |
E | firstElement()
Returns the first component of this vector. |
E | get(int index) Returns the element at the specified posision in this vector. |
int | indexOf(Object elem)
Returns the first (and only) occurrence of the given argument, testing
for equality using the equals method. |
int | indexOf(Object elem, int index)
Returns the first occurrence of the given argument, beginning the search
at index , and testing for equality using the
equals method. |
void | insertElementAt(E obj, int index)
Inserts the specified object as a component in this vector at the
specified index . |
boolean | isEmpty()
Tests if this vector has no components. |
E | lastElement()
Returns the last component of the vector. |
int | lastIndexOf(Object elem)
Returns the index of the last (and only) occurrence of the specified
object in this vector. |
int | lastIndexOf(Object elem, int index)
Searches backwards for the specified object, starting from the
specified index, and returns an index to it. |
E | remove(int index) Removes the element at the specified position in this vector. |
void | removeAllElements()
Removes all components from this vector and sets its size to zero. |
boolean | removeElement(Object obj)
Removes the first (and only) occurance of the argument from this
vector. |
void | removeElementAt(int index)
Deletes the component at the specified index. |
E | set(int index, E obj) Replaces the element at the specified position in this vector with the
specified element. |
void | setElementAt(E obj, int index)
Sets the component at the specified index of this vector
to be the specified object. |
int | size()
Returns the number of components in this vector. |
Object[] | toArray() |
<T> T[] | toArray(T[] a) |
String | toString()
Returns a string representation of this vector. |
void | trimToSize()
Trims the capacity of this vector to be the vector's current size.
|
Collection
, in the order they are returned by the
collection's iterator. Duplicate elements are skipped.Parameters: obj the element to be inserted.
Parameters: obj the component to be added.
Parameters: obj the component to be added.
Throws: UnsupportedOperationException not supported.
Returns: a clone of this vector.
Throws: CloneNotSupportedException if the UniqueVector cannot be cloned.
Parameters: elem an object
Returns: true
if the specified object is a component in
this vector; false
otherwise.
Parameters: anArray the array into which the components get copied.
Parameters: index an index into this vector.
Returns: the component at the specified index.
Throws: ArrayIndexOutOfBoundsException if an invalid index was given.
Parameters: minCapacity the desired minimum capacity.
Returns: the first component of this vector.
Throws: java.util.NoSuchElementException if this vector has no components.
equals
method.Parameters: elem an object
Returns: the index of the first occurrence of the argument in this
vector; returns -1
if the object is not found.
index
, and testing for equality using the
equals
method.Parameters: elem an object. index the index to start searching from.
Returns: the index of the first occurrence of the object argument in this
vector at position index
or later in the vector;
returns -1
if the object is not found.
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.
To maintain uniqueness, removed any previous instance of the component in the vector before insertion.
Parameters: obj the component to insert. index where to insert the new component.
Throws: ArrayIndexOutOfBoundsException if the index was invalid.
Returns: true
if this vector has no components;
false
otherwise.
Returns: the last component of the vector, i.e., the component at
index size()-1
.
Throws: java.util.NoSuchElementException if this vector is empty.
Parameters: elem the desired component.
Returns: the index of the last occurrence of the specified object in
this vector; returns -1
if the object is not
found.
Parameters: elem the desired component. index the index to start searching from.
Returns: the index of the last occurrence of the specified object in
this vector at position less than index
in
the vector; -1
if the object is not found.
Parameters: obj the component to be removed.
Returns: true
if the argument was a component of this vector;
false
otherwise.
index
is shifted downward to have an index one smaller
than the value it had previously.
The index must be a value greater than or equal to 0
and
less than the current size of the vector.
Parameters: index the index of the object to remove.
Throws: ArrayIndexOutOfBoundsException if the index was invalid.
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.
Nothing is done if the component at index is equal to obj. To maintain uniqueness, any component equal to obj is removed before the setElementAt() is done.
Parameters: obj what the component is to be set to. index the specified index.
Throws: ArrayIndexOutOfBoundsException if the index was invalid.
Returns: the number of components in this vector.
Returns: a string representation of this vector.