Class SWMRLong2ObjectHashTable<V>

java.lang.Object
ca.spottedleaf.concurrentutil.map.SWMRLong2ObjectHashTable<V>

public class SWMRLong2ObjectHashTable<V> extends Object
  • Field Details

    • size

      protected int size
    • table

    • loadFactor

      protected final float loadFactor
    • SIZE_HANDLE

      protected static final VarHandle SIZE_HANDLE
    • TABLE_HANDLE

      protected static final VarHandle TABLE_HANDLE
    • DEFAULT_CAPACITY

      protected static final int DEFAULT_CAPACITY
      See Also:
    • DEFAULT_LOAD_FACTOR

      protected static final float DEFAULT_LOAD_FACTOR
      See Also:
    • MAXIMUM_CAPACITY

      protected static final int MAXIMUM_CAPACITY
      See Also:
    • threshold

      protected int threshold
  • Constructor Details

    • SWMRLong2ObjectHashTable

      public SWMRLong2ObjectHashTable()
      Constructs this map with a capacity of 16 and load factor of 0.75f.
    • SWMRLong2ObjectHashTable

      public SWMRLong2ObjectHashTable(int capacity)
      Constructs this map with the specified capacity and load factor of 0.75f.
      Parameters:
      capacity - specified initial capacity, > 0
    • SWMRLong2ObjectHashTable

      public SWMRLong2ObjectHashTable(int capacity, float loadFactor)
      Constructs this map with the specified capacity and load factor.
      Parameters:
      capacity - specified capacity, > 0
      loadFactor - specified load factor, > 0 && finite
    • SWMRLong2ObjectHashTable

      public SWMRLong2ObjectHashTable(SWMRLong2ObjectHashTable<V> other)
      Constructs this map with a capacity of 16 or the specified map's size, whichever is larger, and with a load factor of 0.75f. All of the specified map's entries are copied into this map.
      Parameters:
      other - The specified map.
    • SWMRLong2ObjectHashTable

      public SWMRLong2ObjectHashTable(int capacity, SWMRLong2ObjectHashTable<V> other)
      Constructs this map with a minimum capacity of the specified capacity or the specified map's size, whichever is larger, and with a load factor of 0.75f. All of the specified map's entries are copied into this map.
      Parameters:
      capacity - specified capacity, > 0
      other - The specified map.
    • SWMRLong2ObjectHashTable

      public SWMRLong2ObjectHashTable(int capacity, float loadFactor, SWMRLong2ObjectHashTable<V> other)
      Constructs this map with a min capacity of the specified capacity or the specified map's size, whichever is larger, and with the specified load factor. All of the specified map's entries are copied into this map.
      Parameters:
      capacity - specified capacity, > 0
      loadFactor - specified load factor, > 0 && finite
      other - The specified map.
  • Method Details

    • getSizePlain

      protected final int getSizePlain()
    • getSizeOpaque

      protected final int getSizeOpaque()
    • getSizeAcquire

      protected final int getSizeAcquire()
    • setSizePlain

      protected final void setSizePlain(int value)
    • setSizeOpaque

      protected final void setSizeOpaque(int value)
    • setSizeRelease

      protected final void setSizeRelease(int value)
    • getTablePlain

      protected final SWMRLong2ObjectHashTable.TableEntry<V>[] getTablePlain()
    • getTableAcquire

      protected final SWMRLong2ObjectHashTable.TableEntry<V>[] getTableAcquire()
    • setTablePlain

      protected final void setTablePlain(SWMRLong2ObjectHashTable.TableEntry<V>[] table)
    • setTableRelease

      protected final void setTableRelease(SWMRLong2ObjectHashTable.TableEntry<V>[] table)
    • getAtIndexOpaque

      protected static <V> SWMRLong2ObjectHashTable.TableEntry<V> getAtIndexOpaque(SWMRLong2ObjectHashTable.TableEntry<V>[] table, int index)
    • setAtIndexRelease

      protected static <V> void setAtIndexRelease(SWMRLong2ObjectHashTable.TableEntry<V>[] table, int index, SWMRLong2ObjectHashTable.TableEntry<V> value)
    • getLoadFactor

      public final float getLoadFactor()
    • getCapacityFor

      protected static int getCapacityFor(int capacity)
    • getEntryForOpaque

      protected final SWMRLong2ObjectHashTable.TableEntry<V> getEntryForOpaque(long key)
      Callers must still use acquire when reading the value of the entry.
    • getEntryForPlain

      protected final SWMRLong2ObjectHashTable.TableEntry<V> getEntryForPlain(long key)
    • getHash

      protected static int getHash(long key)
      must be deterministic given a key
    • getTargetCapacity

      protected static int getTargetCapacity(int capacity, float loadFactor)
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      public SWMRLong2ObjectHashTable<V> clone()
      Overrides:
      clone in class Object
    • forEach

      public void forEach(Consumer<? super SWMRLong2ObjectHashTable.TableEntry<V>> action)
    • forEach

      public void forEach(BiLongObjectConsumer<? super V> action)
    • forEachKey

      public void forEachKey(LongConsumer action)
      Provides the specified consumer with all keys contained within this map.
      Parameters:
      action - The specified consumer.
    • forEachValue

      public void forEachValue(Consumer<? super V> action)
      Provides the specified consumer with all values contained within this map. Equivalent to map.values().forEach(Consumer).
      Parameters:
      action - The specified consumer.
    • get

      public V get(long key)
    • containsKey

      public boolean containsKey(long key)
    • getOrDefault

      public V getOrDefault(long key, V defaultValue)
    • size

      public int size()
    • isEmpty

      public boolean isEmpty()
    • checkResize

      protected final void checkResize(int minCapacity)
    • addToSize

      protected final int addToSize(int num)
    • removeFromSize

      protected final int removeFromSize(int num)
    • put

      protected final V put(long key, V value, boolean onlyIfAbsent)
    • put

      public V put(long key, V value)
    • putIfAbsent

      public V putIfAbsent(long key, V value)
    • remove

      protected final V remove(long key, int hash)
    • remove

      protected final V remove(long key, int hash, V expect)
    • remove

      public V remove(long key)
    • remove

      public boolean remove(long key, V expect)
    • putAll

      public void putAll(SWMRLong2ObjectHashTable<? extends V> map)
    • clear

      public void clear()

      This call is non-atomic and the order that which entries are removed is undefined. The clear operation itself is release ordered, that is, after the clear operation is performed a release fence is performed.