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
/
StrSortVector.java,v
< prev
next >
Wrap
Text File
|
2003-07-14
|
2KB
|
96 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
@//: StrSortVector.java
// Automatically sorted Vector that
// accepts and produces only Strings
import java.util.*;
public class StrSortVector {
private SortVector v = new SortVector(
// Anonymous inner class:
new Compare() {
public boolean
lessThan(Object l, Object r) {
return
((String)l).toLowerCase().compareTo(
((String)r).toLowerCase()) < 0;
}
public boolean
lessThanOrEqual(Object l, Object r) {
return
((String)l).toLowerCase().compareTo(
((String)r).toLowerCase()) <= 0;
}
}
);
private boolean sorted = false;
public void addElement(String s) {
v.addElement(s);
sorted = false;
}
public String elementAt(int index) {
if(!sorted) {
v.sort();
sorted = true;
}
return (String)v.elementAt(index);
}
public Enumeration elements() {
if(!sorted) {
v.sort();
sorted = true;
}
return v.elements();
}
// Test it:
public static void main(String[] args) {
StrSortVector sv = new StrSortVector();
sv.addElement("d");
sv.addElement("A");
sv.addElement("C");
sv.addElement("c");
sv.addElement("b");
sv.addElement("B");
sv.addElement("D");
sv.addElement("a");
Enumeration e = sv.elements();
while(e.hasMoreElements())
System.out.println(e.nextElement());
}
} ///:~
@
1.1
log
@Trying to sync.
@
text
@@