public class SortedVector
extends java.lang.Object
All elements inserted into an sorted vector must implement the Comparable interface (or be accepted by the specified Comparator). Furthermore, all such elements must be mutually comparable: e1.compareTo(e2) (or comparator.compare(e1, e2)) must not throw a ClassCastException for any elements e1 and e2 in the sorted set.
Constructor and Description |
---|
SortedVector()
Creates a new SortedVector.
|
SortedVector(java.util.Collection elements)
Creates a new SortedVector.
|
SortedVector(java.util.Comparator comparator)
Creates a new SortedVector.
|
Modifier and Type | Method and Description |
---|---|
void |
addElement(java.lang.Object obj)
Adds the specified element to this vector maintaining the ascending order.
|
void |
addElements(java.util.Collection elements)
Adds all of the elements in the specified collection to this vector.
|
void |
addElements(java.lang.Object[] elements)
Adds all of the elements in the specified collection to this vector.
|
void |
clear()
Removes all of the elements from this vector.
|
java.lang.Object |
elementAt(int i)
Gets the element at the specified index.
|
java.util.Enumeration |
elements()
Gets an enumeration of the components of this vector.
|
java.util.Iterator |
iterator()
Gets an iterator over the elements in this list in proper sequence.
|
void |
removeElementAt(int i)
Removes the element at the specified index.
|
int |
size()
Gets the vector size.
|
java.lang.Object[] |
toArray()
Gets an array containing all of the elements in this vector in the correct order.
|
java.lang.Object[] |
toArray(java.lang.Object[] a)
Gets an array containing all of the elements in this vector in the correct order.
|
java.util.Vector |
toVector()
Gets a new vector containing all of the elements in this vector in the correct order.
|
public SortedVector()
public SortedVector(java.util.Collection elements)
elements
- elements to be inserted into this vectorpublic SortedVector(java.util.Comparator comparator)
comparator
- the comparator that will be used to sort this set. A null value indicates that the elements' natural ordering should be usedpublic int size()
public void clear()
public void addElements(java.util.Collection elements)
elements
- elements to be inserted into this vectorpublic void addElements(java.lang.Object[] elements)
elements
- elements to be inserted into this vectorpublic void addElement(java.lang.Object obj)
obj
- the element to be addedpublic java.lang.Object elementAt(int i)
i
- an index into this vectorpublic void removeElementAt(int i)
i
- an index into this vectorpublic java.util.Enumeration elements()
public java.util.Iterator iterator()
public java.util.Vector toVector()
public java.lang.Object[] toArray()
public java.lang.Object[] toArray(java.lang.Object[] a)
a
- the specified array