jds.sort
Class Partition
java.lang.Object
|
+--jds.sort.Partition
- public class Partition
- extends java.lang.Object
- implements FindNth, SortAlgorithm
Partition - algorithms involving partitioning a vector into groups;
for use with book
Classic Data Structures
in Java
by Timothy A Budd,
published by Addison-Wesley, 2001.
Constructor Summary |
Partition(java.util.Comparator c)
initialize a new Parition object |
Partition(Indexed v,
java.util.Comparator c)
initialize a new Parition object |
Method Summary |
java.lang.Object |
findNth(int n)
find nth smallest value in collection |
void |
sort(Indexed data)
rearrange collection into asending order |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Partition
public Partition(java.util.Comparator c)
- initialize a new Parition object
- Parameters:
c
- the Comparator used to place values in order
Partition
public Partition(Indexed v,
java.util.Comparator c)
- initialize a new Parition object
- Parameters:
v
- an Indexed object of initial valuesc
- the Comparator used to place values in order
findNth
public java.lang.Object findNth(int n)
- find nth smallest value in collection
- Specified by:
- findNth in interface FindNth
- Parameters:
index
- of value, from 0 to (size-1)
- Returns:
- value of element
- Throws:
- java.util.NoSuchElementException - index is illegal
sort
public void sort(Indexed data)
- rearrange collection into asending order
- Specified by:
- sort in interface SortAlgorithm
- Parameters:
data
- the values to be ordered