mss.ea.core
Class SortedVector
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.Vector
|
+--mss.ea.core.SortedVector
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable
- public class SortedVector
- extends java.util.Vector
Sorted vector.
This implementation of a vector guarantees, that all contained elements are sorted.
The elemntens must implement the interface Comparable or a Comparator must be given
with the method setComparator().
- Since:
- 0.1
- Version:
- 0.1 (10-03-00)
- Author:
- Andreas Rummler
- See Also:
- Serialized Form
Fields inherited from class java.util.Vector |
capacityIncrement, elementCount, elementData |
Fields inherited from class java.util.AbstractList |
modCount |
Method Summary |
void |
add(int index,
java.lang.Object element)
|
boolean |
add(java.lang.Object element)
|
void |
add(java.lang.Object[] array)
Inserts an array into the vector. |
boolean |
addAll(java.util.Collection c)
|
boolean |
addAll(int index,
java.util.Collection c)
|
void |
addElement(java.lang.Object obj)
|
protected int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compares two elements.
|
void |
deleteRange(int fromIndex,
int toIndex)
Deletes a range in the vector.
|
protected int |
insert(java.lang.Object c)
Inserts a new element.
|
void |
insertElementAt(java.lang.Object obj,
int index)
|
java.lang.Object |
search(java.lang.Object o)
Performs a binary search on the sorted vector. |
void |
setComparator(java.util.Comparator c)
Sets a new comparator. |
void |
setElementAt(java.lang.Object obj,
int index)
|
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, set, 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.List |
iterator, listIterator, listIterator |
SortedVector
public SortedVector()
SortedVector
public SortedVector(java.util.Collection c)
SortedVector
public SortedVector(int initialCapacity)
SortedVector
public SortedVector(int initialCapacity,
int capacityIncrement)
add
public boolean add(java.lang.Object element)
- Overrides:
add
in class java.util.Vector
add
public void add(int index,
java.lang.Object element)
- Overrides:
add
in class java.util.Vector
addAll
public boolean addAll(java.util.Collection c)
- Overrides:
addAll
in class java.util.Vector
addAll
public boolean addAll(int index,
java.util.Collection c)
- Overrides:
addAll
in class java.util.Vector
addElement
public void addElement(java.lang.Object obj)
- Overrides:
addElement
in class java.util.Vector
insertElementAt
public void insertElementAt(java.lang.Object obj,
int index)
- Overrides:
insertElementAt
in class java.util.Vector
setElementAt
public void setElementAt(java.lang.Object obj,
int index)
- Overrides:
setElementAt
in class java.util.Vector
insert
protected int insert(java.lang.Object c)
- Inserts a new element.
This is the only possibility to insert a new element. This is necessary to guarantee that
the elements are sorted. All overloaded methods use this method.
- Parameters:
c
- element to insert- Returns:
- position the object was inserted at
search
public java.lang.Object search(java.lang.Object o)
- Performs a binary search on the sorted vector.
- Parameters:
o
- Object to search for using the set comparator- Returns:
- the found object from the vector or Null instead
compare
protected int compare(java.lang.Object o1,
java.lang.Object o2)
- Compares two elements.
This is done using the given comparator. If that fails, both objects are casted to Comparable.
A o1.compareTo( o2 ) is invoked afterwards.
- Parameters:
o1
- first objecto2
- second object- Returns:
- result of comparison
add
public void add(java.lang.Object[] array)
- Inserts an array into the vector.
- Parameters:
array
- array to insert into the vector
deleteRange
public void deleteRange(int fromIndex,
int toIndex)
- Deletes a range in the vector.
The range is between fromIndex (inclusive) to toIndex (exclusive). This is a wrapper for
Vector.removeRange(), that is set to protective (who knows why ...).
- Parameters:
fromIndex
- lower indextoIndex
- upper index
setComparator
public void setComparator(java.util.Comparator c)
- Sets a new comparator.
- Parameters:
c
- new comparator
Copyright © 2000-2001 Technical University of Ilmenau, Department ESS