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
-
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
compare
in interfaceComparator<E>
- Parameters:
a
- the first of two elements to compareb
- the second of two elements to compare- Returns:
- a negative integer if
a
is less thanb
, zero ifa
equalsb
, or a positive integer ifa
is greater thanb
- Throws:
ClassCastException
-