|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmckay.utilities.vectorsorter.StringSortableVector
public class StringSortableVector
A simplistic example of how the SortableVector class might be used in practice. This implementation assumes that the vector is storing and sorting strings. An internal class is included that implements QuicksortComparator.
This class might be used as follows, for example:
StringSortableVector sv = new StringSortableVector();
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());
This approach to the QuickSort algorithm is derived from Bruce Eckel's implementation, which can be found at: http://www.codeguru.com/java/tij/tij0091.shtml
Constructor Summary | |
---|---|
StringSortableVector()
Initializes the object. |
Method Summary | |
---|---|
void |
addElement(java.lang.String s)
Adds the given string to the SortableVector stored in this object. |
java.lang.String |
elementAt(int index)
Returns the string stored at the given index of the SortableVector stored in this object. |
java.util.Enumeration |
elements()
Returns an Enumeration of all elements stored in the SortableVector stored in this object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringSortableVector()
Method Detail |
---|
public void addElement(java.lang.String s)
s
- The string to add.public java.lang.String elementAt(int index)
index
- The post-sorting index of the object to return.
public java.util.Enumeration elements()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |