0001 /* 0002 * 按照字典序确定平面点之间次序的比较器 0003 */ 0004 0005 package dsa; 0006 0007 public class ComparatorLexicographic implements Comparator { 0008 public int compare(Object a, Object b) throws ClassCastException { 0009 int ax = ((Point2D) a).getX(); 0010 int ay = ((Point2D) a).getY(); 0011 int bx = ((Point2D) b).getX(); 0012 int by = ((Point2D) b).getY(); 0013 return (ax != bx) ? (ax - bx) : (ay - by); 0014 } 0015 }