FileDocCategorySizeDatePackage
StrSortVector.javaAPI DocExample3801Mon Apr 06 18:10:24 BST 1998c08

StrSortVector

public class StrSortVector extends Object

Fields Summary
private SortVector
v
private boolean
sorted
Constructors Summary
Methods Summary
public voidaddElement(java.lang.String s)

      
    v.addElement(s);
    sorted = false;
  
public java.lang.StringelementAt(int index)

    if(!sorted) {
      v.sort();
      sorted = true;
    }
    return (String)v.elementAt(index);
  
public java.util.Enumerationelements()

    if(!sorted) {
      v.sort();
      sorted = true;
    }
    return v.elements();
  
public static voidmain(java.lang.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());