private int compare ( Object key1 , Object key2 ) { if ( comparator == null ) return ( ( Comparable ) key1 ) . compareTo ( key2 ) ; else return comparator . compare ( key1 , key2 ) ; }
Use the comparator to compare the two keys .