Class ConcurrentSkipListMap.ConcurrentSkipListSubMap<K,​V>

  • All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.ConcurrentMap<K,​V>, java.util.Map<K,​V>, java.util.SortedMap<K,​V>, ConcurrentNavigableMap<K,​V>, NavigableMap<K,​V>
    Enclosing class:
    ConcurrentSkipListMap<K,​V>

    static class ConcurrentSkipListMap.ConcurrentSkipListSubMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    implements ConcurrentNavigableMap<K,​V>, java.io.Serializable
    Submaps returned by ConcurrentSkipListMap submap operations represent a subrange of mappings of their underlying maps. Instances of this class support all methods of their underlying maps, differing in that mappings outside their range are ignored, and attempts to add mappings outside their ranges result in IllegalArgumentException. Instances of this class are constructed only using the subMap, headMap, and tailMap methods of their underlying maps.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map.Entry<K,​V> ceilingEntry​(K key)
      Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such entry.
      K ceilingKey​(K key)
      Returns least key greater than or equal to the given key, or null if there is no such key.
      (package private) void checkKey​(K key)  
      void clear()  
      java.util.Comparator<? super K> comparator()  
      boolean containsKey​(java.lang.Object key)  
      boolean containsValue​(java.lang.Object value)  
      java.util.Set<java.util.Map.Entry<K,​V>> descendingEntrySet()
      Returns a set view of the mappings contained in this map, in descending key order.
      java.util.Set<K> descendingKeySet()
      Returns a set view of the keys contained in this map, in descending key order.
      java.util.Set<java.util.Map.Entry<K,​V>> entrySet()  
      java.util.Map.Entry<K,​V> firstEntry()
      Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
      K firstKey()  
      (package private) ConcurrentSkipListMap.Node<K,​V> firstNode()  
      java.util.Map.Entry<K,​V> floorEntry​(K key)
      Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such entry.
      K floorKey​(K key)
      Returns the greatest key less than or equal to the given key, or null if there is no such key.
      V get​(java.lang.Object key)  
      (package private) K getFence()
      Returns fence key.
      (package private) K getLeast()
      Returns least key.
      (package private) ConcurrentSkipListMap<K,​V> getMap()
      Returns underlying map.
      ConcurrentNavigableMap<K,​V> headMap​(K toKey)
      Returns a view of the portion of this map whose keys are strictly less than toKey.
      java.util.Map.Entry<K,​V> higherEntry​(K key)
      Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such entry.
      K higherKey​(K key)
      Returns the least key strictly greater than the given key, or null if there is no such key.
      (package private) boolean inHalfOpenRange​(K key)  
      (package private) boolean inOpenRange​(K key)  
      (package private) boolean isBeforeEnd​(ConcurrentSkipListMap.Node<K,​V> n)  
      boolean isEmpty()  
      java.util.Set<K> keySet()  
      java.util.Map.Entry<K,​V> lastEntry()
      Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
      K lastKey()  
      (package private) ConcurrentSkipListMap.Node<K,​V> lastNode()  
      java.util.Map.Entry<K,​V> lowerEntry​(K key)
      Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such entry.
      K lowerKey​(K key)
      Returns the greatest key strictly less than the given key, or null if there is no such key.
      java.util.Map.Entry<K,​V> pollFirstEntry()
      Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
      java.util.Map.Entry<K,​V> pollLastEntry()
      Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
      V put​(K key, V value)  
      V putIfAbsent​(K key, V value)  
      V remove​(java.lang.Object key)  
      boolean remove​(java.lang.Object key, java.lang.Object value)  
      V replace​(K key, V value)  
      boolean replace​(K key, V oldValue, V newValue)  
      int size()  
      ConcurrentNavigableMap<K,​V> subMap​(K fromKey, K toKey)
      Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
      ConcurrentNavigableMap<K,​V> tailMap​(K fromKey)
      Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
      java.util.Collection<V> values()  
      • Methods inherited from class java.util.AbstractMap

        clone, equals, hashCode, putAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.ConcurrentMap

        compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
      • Methods inherited from interface java.util.Map

        equals, hashCode, putAll
    • Field Detail

      • least

        private final K least
        lower bound key, or null if from start
      • fence

        private final K fence
        upper fence key, or null if to end
      • keySetView

        private transient java.util.Set<K> keySetView
      • entrySetView

        private transient java.util.Set<java.util.Map.Entry<K,​V>> entrySetView
      • valuesView

        private transient java.util.Collection<V> valuesView
      • descendingKeySetView

        private transient java.util.Set<K> descendingKeySetView
      • descendingEntrySetView

        private transient java.util.Set<java.util.Map.Entry<K,​V>> descendingEntrySetView
    • Constructor Detail

      • ConcurrentSkipListSubMap

        ConcurrentSkipListSubMap​(ConcurrentSkipListMap<K,​V> map,
                                 K least,
                                 K fence)
        Creates a new submap.
        Parameters:
        least - inclusive least value, or null if from start
        fence - exclusive upper bound or null if to end
        Throws:
        java.lang.IllegalArgumentException - if least and fence nonnull and least greater than fence
    • Method Detail

      • inHalfOpenRange

        boolean inHalfOpenRange​(K key)
      • inOpenRange

        boolean inOpenRange​(K key)
      • checkKey

        void checkKey​(K key)
               throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • getMap

        ConcurrentSkipListMap<K,​V> getMap()
        Returns underlying map. Needed by ConcurrentSkipListSet
        Returns:
        the backing map
      • getLeast

        K getLeast()
        Returns least key. Needed by ConcurrentSkipListSet
        Returns:
        least key or null if from start
      • getFence

        K getFence()
        Returns fence key. Needed by ConcurrentSkipListSet
        Returns:
        fence key or null of to end
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        Overrides:
        containsKey in class java.util.AbstractMap<K,​V>
      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get in class java.util.AbstractMap<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.AbstractMap<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class java.util.AbstractMap<K,​V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Overrides:
        size in class java.util.AbstractMap<K,​V>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
        Overrides:
        isEmpty in class java.util.AbstractMap<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Overrides:
        containsValue in class java.util.AbstractMap<K,​V>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear in class java.util.AbstractMap<K,​V>
      • putIfAbsent

        public V putIfAbsent​(K key,
                             V value)
        Specified by:
        putIfAbsent in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        putIfAbsent in interface java.util.Map<K,​V>
      • remove

        public boolean remove​(java.lang.Object key,
                              java.lang.Object value)
        Specified by:
        remove in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        remove in interface java.util.Map<K,​V>
      • replace

        public boolean replace​(K key,
                               V oldValue,
                               V newValue)
        Specified by:
        replace in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        replace in interface java.util.Map<K,​V>
      • replace

        public V replace​(K key,
                         V value)
        Specified by:
        replace in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        replace in interface java.util.Map<K,​V>
      • comparator

        public java.util.Comparator<? super K> comparator()
        Specified by:
        comparator in interface java.util.SortedMap<K,​V>
      • firstKey

        public K firstKey()
        Specified by:
        firstKey in interface java.util.SortedMap<K,​V>
      • lastKey

        public K lastKey()
        Specified by:
        lastKey in interface java.util.SortedMap<K,​V>
      • subMap

        public ConcurrentNavigableMap<K,​V> subMap​(K fromKey,
                                                        K toKey)
        Description copied from interface: ConcurrentNavigableMap
        Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned sorted map is empty.) The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa.
        Specified by:
        subMap in interface ConcurrentNavigableMap<K,​V>
        Specified by:
        subMap in interface NavigableMap<K,​V>
        Specified by:
        subMap in interface java.util.SortedMap<K,​V>
        Parameters:
        fromKey - low endpoint (inclusive) of the subMap.
        toKey - high endpoint (exclusive) of the subMap.
        Returns:
        a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
      • headMap

        public ConcurrentNavigableMap<K,​V> headMap​(K toKey)
        Description copied from interface: ConcurrentNavigableMap
        Returns a view of the portion of this map whose keys are strictly less than toKey. The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa.
        Specified by:
        headMap in interface ConcurrentNavigableMap<K,​V>
        Specified by:
        headMap in interface NavigableMap<K,​V>
        Specified by:
        headMap in interface java.util.SortedMap<K,​V>
        Parameters:
        toKey - high endpoint (exclusive) of the headMap.
        Returns:
        a view of the portion of this map whose keys are strictly less than toKey.
      • tailMap

        public ConcurrentNavigableMap<K,​V> tailMap​(K fromKey)
        Description copied from interface: ConcurrentNavigableMap
        Returns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa.
        Specified by:
        tailMap in interface ConcurrentNavigableMap<K,​V>
        Specified by:
        tailMap in interface NavigableMap<K,​V>
        Specified by:
        tailMap in interface java.util.SortedMap<K,​V>
        Parameters:
        fromKey - low endpoint (inclusive) of the tailMap.
        Returns:
        a view of the portion of this map whose keys are greater than or equal to fromKey.
      • ceilingEntry

        public java.util.Map.Entry<K,​V> ceilingEntry​(K key)
        Description copied from interface: NavigableMap
        Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such entry.
        Specified by:
        ceilingEntry in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        an Entry associated with ceiling of given key, or null if there is no such Entry.
      • ceilingKey

        public K ceilingKey​(K key)
        Description copied from interface: NavigableMap
        Returns least key greater than or equal to the given key, or null if there is no such key.
        Specified by:
        ceilingKey in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        the ceiling key, or null if there is no such key.
      • lowerEntry

        public java.util.Map.Entry<K,​V> lowerEntry​(K key)
        Description copied from interface: NavigableMap
        Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such entry.
        Specified by:
        lowerEntry in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        an Entry with greatest key less than the given key, or null if there is no such Entry.
      • lowerKey

        public K lowerKey​(K key)
        Description copied from interface: NavigableMap
        Returns the greatest key strictly less than the given key, or null if there is no such key.
        Specified by:
        lowerKey in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        the greatest key less than the given key, or null if there is no such key.
      • floorEntry

        public java.util.Map.Entry<K,​V> floorEntry​(K key)
        Description copied from interface: NavigableMap
        Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such entry.
        Specified by:
        floorEntry in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        an Entry associated with floor of given key, or null if there is no such Entry.
      • floorKey

        public K floorKey​(K key)
        Description copied from interface: NavigableMap
        Returns the greatest key less than or equal to the given key, or null if there is no such key.
        Specified by:
        floorKey in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        the floor of given key, or null if there is no such key.
      • higherEntry

        public java.util.Map.Entry<K,​V> higherEntry​(K key)
        Description copied from interface: NavigableMap
        Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such entry.
        Specified by:
        higherEntry in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        an Entry with least key greater than the given key, or null if there is no such Entry.
      • higherKey

        public K higherKey​(K key)
        Description copied from interface: NavigableMap
        Returns the least key strictly greater than the given key, or null if there is no such key.
        Specified by:
        higherKey in interface NavigableMap<K,​V>
        Parameters:
        key - the key.
        Returns:
        the least key greater than the given key, or null if there is no such key.
      • firstEntry

        public java.util.Map.Entry<K,​V> firstEntry()
        Description copied from interface: NavigableMap
        Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
        Specified by:
        firstEntry in interface NavigableMap<K,​V>
        Returns:
        an Entry with least key, or null if the map is empty.
      • lastEntry

        public java.util.Map.Entry<K,​V> lastEntry()
        Description copied from interface: NavigableMap
        Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
        Specified by:
        lastEntry in interface NavigableMap<K,​V>
        Returns:
        an Entry with greatest key, or null if the map is empty.
      • pollFirstEntry

        public java.util.Map.Entry<K,​V> pollFirstEntry()
        Description copied from interface: NavigableMap
        Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
        Specified by:
        pollFirstEntry in interface NavigableMap<K,​V>
        Returns:
        the removed first entry of this map, or null if the map is empty.
      • pollLastEntry

        public java.util.Map.Entry<K,​V> pollLastEntry()
        Description copied from interface: NavigableMap
        Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
        Specified by:
        pollLastEntry in interface NavigableMap<K,​V>
        Returns:
        the removed last entry of this map, or null if the map is empty.
      • keySet

        public java.util.Set<K> keySet()
        Specified by:
        keySet in interface java.util.Map<K,​V>
        Specified by:
        keySet in interface java.util.SortedMap<K,​V>
        Overrides:
        keySet in class java.util.AbstractMap<K,​V>
      • descendingKeySet

        public java.util.Set<K> descendingKeySet()
        Description copied from interface: NavigableMap
        Returns a set view of the keys contained in this map, in descending key order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation), the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll retainAll, and clear operations. It does not support the add or addAll operations.
        Specified by:
        descendingKeySet in interface NavigableMap<K,​V>
        Returns:
        a set view of the keys contained in this map.
      • values

        public java.util.Collection<V> values()
        Specified by:
        values in interface java.util.Map<K,​V>
        Specified by:
        values in interface java.util.SortedMap<K,​V>
        Overrides:
        values in class java.util.AbstractMap<K,​V>
      • entrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in interface java.util.SortedMap<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • descendingEntrySet

        public java.util.Set<java.util.Map.Entry<K,​V>> descendingEntrySet()
        Description copied from interface: NavigableMap
        Returns a set view of the mappings contained in this map, in descending key order. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
        Specified by:
        descendingEntrySet in interface NavigableMap<K,​V>
        Returns:
        a set view of the mappings contained in this map.