data_structures_free

This commit is contained in:
2014-03-24 18:47:50 +01:00
commit 6f92828c96
65 changed files with 4738 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
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<E> implements Comparator<E> {
//end#fragment DefaultComparator
/** Compares two given elements
*
* @return a negative integer if <tt>a</tt> is less than <tt>b</tt>,
* zero if <tt>a</tt> equals <tt>b</tt>, or a positive integer if
* <tt>a</tt> is greater than <tt>b</tt>
*/
//begin#fragment DefaultComparator
public int compare(E a, E b) throws ClassCastException {
return ((Comparable<E>) a).compareTo(b);
}
}
//end#fragment DefaultComparator