Java Utililty Methods Vector Sort

List of utility methods to do Vector Sort

  1. HOME
  2. Java
  3. V
  4. Vector Sort

Description

The list of methods to do Vector Sort are organized into topic(s).

Method

Vector sort(Vector unsorted, int sortKeyPos, int maxVal)
Sorts the elements of a Vector.
int listSize = unsorted.size();
Vector sorted = (Vector) unsorted.clone();
int[] map = new int[maxVal];
int index = -1;
for (int i = 0; i < listSize; i++) {
 index = ((Integer) (((Object[]) unsorted.elementAt(i))[sortKeyPos])).intValue();
 if (index > maxVal)
 throw new IllegalArgumentException("Incorrect maxVal");
...
void sortInsert(Vector v, Object obj)
sort Insert
Enumeration e = v.elements();
for (int i = 0; i < v.size(); i++) {
 Object cur = v.elementAt(i);
 if (obj.toString().compareTo(cur.toString()) < 0) {
 v.insertElementAt(obj, i);
 return;
v.addElement(obj);
Vector sortIntegerVector(Vector toSort)
Sorts an vector.
if (toSort == null) {
 return new Vector();
int size = toSort.size();
if (size == 0) {
 return toSort;
Vector sorted = new Vector();
...

AltStyle によって変換されたページ (->オリジナル) /