Package com.zybooks.dsaj.util
Class DefaultComparator<E>
java.lang.Object
com.zybooks.dsaj.util.DefaultComparator<E>
- Type Parameters:
E- an element type
- All Implemented Interfaces:
Comparator<E>
Comparator based on the compareTo method of a Comparable element type.
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
DefaultComparator
public DefaultComparator()
-
-
Method Details
-
compare
Compares two elements.- Specified by:
comparein interfaceComparator<E>- Parameters:
a- the first of two elements to compareb- the second of two elements to compare- Returns:
- a negative integer if
ais less thanb, zero ifaequalsb, or a positive integer ifais greater thanb - Throws:
ClassCastException
-