net.sf.beanlib.util.concurrent
Class ConcurrentSkipListMap.ComparableUsingComparator<K>
java.lang.Object
net.sf.beanlib.util.concurrent.ConcurrentSkipListMap.ComparableUsingComparator<K>
- All Implemented Interfaces:
- Comparable<K>
- Enclosing class:
- ConcurrentSkipListMap<K,V>
static final class ConcurrentSkipListMap.ComparableUsingComparator<K>
- extends Object
- implements Comparable<K>
Represents a key with a comparator as a Comparable.
Because most sorted collections seem to use natural ordering on
Comparables (Strings, Integers, etc), most internal methods are
geared to use them. This is generally faster than checking
per-comparison whether to use comparator or comparable because
it doesn't require a (Comparable) cast for each comparison.
(Optimizers can only sometimes remove such redundant checks
themselves.) When Comparators are used,
ComparableUsingComparators are created so that they act in the
same way as natural orderings. This penalizes use of
Comparators vs Comparables, which seems like the right
tradeoff.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
actualKey
final K actualKey
cmp
final Comparator<? super K> cmp
ConcurrentSkipListMap.ComparableUsingComparator
ConcurrentSkipListMap.ComparableUsingComparator(K key,
Comparator<? super K> cmp)
compareTo
public int compareTo(K k2)
- Specified by:
compareTo
in interface Comparable<K>