Class UnlockedHashMap<K,​V>

  • Type Parameters:
    K - the key type
    V - the value type
    All Implemented Interfaces:
    java.util.concurrent.ConcurrentMap<K,​V>, java.util.Map<K,​V>

    final class UnlockedHashMap<K,​V>
    extends java.util.AbstractMap<K,​V>
    implements java.util.concurrent.ConcurrentMap<K,​V>
    Lock-free concurrent hash map.
    • Field Detail

      • DEFAULT_INITIAL_CAPACITY

        private static final int DEFAULT_INITIAL_CAPACITY
        See Also:
        Constant Field Values
      • RESIZED

        private static final UnlockedHashMap.Item<?,​?>[] RESIZED
        A row which has been resized into the new view.
      • NONEXISTENT

        private static final java.lang.Object NONEXISTENT
        A non-existent table entry (as opposed to a null value).
      • keySet

        private final java.util.Set<K> keySet
      • entrySet

        private final java.util.Set<java.util.Map.Entry<K,​V>> entrySet
      • values

        private final java.util.Collection<V> values
      • loadFactor

        private final float loadFactor
      • initialCapacity

        private final int initialCapacity
      • sizeUpdater

        private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<UnlockedHashMap.Table> sizeUpdater
      • valueUpdater

        private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<UnlockedHashMap.Item,​java.lang.Object> valueUpdater
    • Constructor Detail

      • UnlockedHashMap

        public UnlockedHashMap​(int initialCapacity,
                               float loadFactor)
        Construct a new instance.
        Parameters:
        initialCapacity - the initial capacity
        loadFactor - the load factor
      • UnlockedHashMap

        public UnlockedHashMap​(float loadFactor)
        Construct a new instance.
        Parameters:
        loadFactor - the load factor
      • UnlockedHashMap

        public UnlockedHashMap​(int initialCapacity)
        Construct a new instance.
        Parameters:
        initialCapacity - the initial capacity
      • UnlockedHashMap

        public UnlockedHashMap()
        Construct a new instance.
    • Method Detail

      • hashCode

        private static int hashCode​(java.lang.Object key)
      • 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 objectKey,
                              java.lang.Object objectValue)
        Specified by:
        remove in interface java.util.concurrent.ConcurrentMap<K,​V>
        Specified by:
        remove in interface java.util.Map<K,​V>
      • remove

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

        private static <V> V nonexistent()
      • 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>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Overrides:
        size in class java.util.AbstractMap<K,​V>
      • 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>
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear 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 class java.util.AbstractMap<K,​V>
      • values

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

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