FileDocCategorySizeDatePackage
SortVector.javaAPI DocExample3343Mon Apr 06 18:10:24 BST 1998c08

SortVector

public class SortVector extends Vector

Fields Summary
private Compare
compare
Constructors Summary
public SortVector(Compare comp)

    compare = comp;
  
Methods Summary
private voidquickSort(int left, int right)

    if(right > left) {
      Object o1 = elementAt(right);
      int i = left - 1;
      int j = right;
      while(true) {
        while(compare.lessThan(
              elementAt(++i), o1))
          ;
        while(j > 0)
          if(compare.lessThanOrEqual(
             elementAt(--j), o1))
            break; // out of while
        if(i >= j) break;
        swap(i, j);
      }
      swap(i , right);
      quickSort(left, i-1);
      quickSort(i+1, right);
    }
  
public voidsort()

    quickSort(0, size() - 1);
  
private voidswap(int loc1, int loc2)

    Object tmp = elementAt(loc1);
    setElementAt(elementAt(loc2), loc1);
    setElementAt(tmp, loc2);