// package net.datastructures; import java.util.Comparator; import java.io.Serializable; /** Comparator based on the natural ordering * * @author Michael Goodrich */ //begin#fragment DefaultComparator public class DefaultComparator implements Comparator { //end#fragment DefaultComparator /** Compares two given elements * * @return a negative integer if a is less than b, * zero if a equals b, or a positive integer if * a is greater than b */ //begin#fragment DefaultComparator public int compare(E a, E b) throws ClassCastException { return ((Comparable) a).compareTo(b); } } //end#fragment DefaultComparator