Class ConcurrentSkipListMap.ComparableUsingComparator<K>

  • All Implemented Interfaces:
    java.lang.Comparable<K>
    Enclosing class:
    ConcurrentSkipListMap<K,​V>

    static final class ConcurrentSkipListMap.ComparableUsingComparator<K>
    extends java.lang.Object
    implements java.lang.Comparable<K>
    Represents a key with a comparator as a Comparable. Because most sorted collections seem to use natural order 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) K actualKey  
      (package private) java.util.Comparator<? super K> cmp  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(K k2)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • actualKey

        final K actualKey
      • cmp

        final java.util.Comparator<? super K> cmp
    • Constructor Detail

      • ComparableUsingComparator

        ComparableUsingComparator​(K key,
                                  java.util.Comparator<? super K> cmp)
    • Method Detail

      • compareTo

        public int compareTo​(K k2)
        Specified by:
        compareTo in interface java.lang.Comparable<K>