home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.pdx.edu
/
2014.02.ftp.ee.pdx.edu.tar
/
ftp.ee.pdx.edu
/
oss
/
cvs-2004
/
OpenHamLog
/
Attic
/
SortVector.java,v
< prev
next >
Wrap
Text File
|
2003-07-14
|
1KB
|
77 lines
head 1.2;
access;
symbols;
locks; strict;
comment @# @;
1.2
date 2003.07.14.19.37.57; author htodd; state dead;
branches;
next 1.1;
1.1
date 2003.07.06.04.27.10; author htodd; state Exp;
branches;
next ;
desc
@@
1.2
log
@Moving files and starting ant.
@
text
@//: SortVector.java
// A generic sorting vector
import java.util.*;
public class SortVector extends Vector {
private Compare compare; // To hold the callback
public SortVector(Compare comp) {
compare = comp;
}
public void sort() {
quickSort(0, size() - 1);
}
private void quickSort(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);
}
}
private void swap(int loc1, int loc2) {
Object tmp = elementAt(loc1);
setElementAt(elementAt(loc2), loc1);
setElementAt(tmp, loc2);
}
} ///:~
@
1.1
log
@Trying to sync.
@
text
@@