package username.sorting; import java.util.Comparator; /** * Things that know how to sort. * * @author CSC152 2006S * @version 1.0 of April 2006 */ public interface Sorter { /** * Sort a vector in increasing order. * * @param vec * The vector to be sorted. * @param c * The comparator that determines the order. * @return sorted * The sorted version of vec. * @pre * The vector is non-empty. (vec.length() > 0) * The comparator should be applicable to any two elements in vec. * (c.compare(vec.get(i),vec.get(j)) does not throw an * exception for any valid i and j). * The comparator is transitive and reflexive and all that stuff. * @post * sorted is sorted. * c.compare(vec.get(i),vec.get(i+1)) <= 0 for any reasonable i * (0 <= i < vec.length()-1) * sorted is a permutation of vec. */ public Vector sort(Vector vec, Comparator c); } // Sorter