collections.sortable
Class Cart
java.lang.Object
collections.sortable.Cart
public class Cart
- extends java.lang.Object
Demonstrates the use of comparable objects and explicit comparators
used for sorting. Objects are added to a HashSet (which is faster)
and then passed into a new TreeSet (which supports sorting).
- Author:
- Thomas Rowland
Constructor Summary |
Cart()
|
Method Summary |
static void |
main(java.lang.String[] args)
|
void |
retrieve(java.util.Set s)
|
void |
sort(java.util.Set set)
Sorts a set (a TreeSet) according to the objects' natural ordering
defined by its conmpareTo method. |
void |
sort(java.util.Set set,
java.util.Comparator comparator)
Sorts a set (a TreeSet) according to the eplicit Comparator. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Cart
public Cart()
main
public static void main(java.lang.String[] args)
retrieve
public void retrieve(java.util.Set s)
sort
public void sort(java.util.Set set)
- Sorts a set (a TreeSet) according to the objects' natural ordering
defined by its conmpareTo method.
sort
public void sort(java.util.Set set,
java.util.Comparator comparator)
- Sorts a set (a TreeSet) according to the eplicit Comparator.