Class SWMRLong2ObjectHashTable<V>
java.lang.Object
ca.spottedleaf.concurrentutil.map.SWMRLong2ObjectHashTable<V>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final floatprotected final floatprotected static final intprotected intprotected static final VarHandleprotected SWMRLong2ObjectHashTable.TableEntry<V>[]protected static final VarHandleprotected int -
Constructor Summary
ConstructorsConstructorDescriptionConstructs this map with a capacity of16and load factor of0.75f.SWMRLong2ObjectHashTable(int capacity) Constructs this map with the specified capacity and load factor of0.75f.SWMRLong2ObjectHashTable(int capacity, float loadFactor) Constructs this map with the specified capacity and load factor.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.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 of0.75f.Constructs this map with a capacity of16or the specified map's size, whichever is larger, and with a load factor of0.75f. -
Method Summary
Modifier and TypeMethodDescriptionprotected final intaddToSize(int num) protected final voidcheckResize(int minCapacity) voidclear()clone()booleancontainsKey(long key) booleanvoidforEach(BiLongObjectConsumer<? super V> action) voidforEach(Consumer<? super SWMRLong2ObjectHashTable.TableEntry<V>> action) voidforEachKey(LongConsumer action) Provides the specified consumer with all keys contained within this map.voidforEachValue(Consumer<? super V> action) Provides the specified consumer with all values contained within this map.get(long key) protected static <V> SWMRLong2ObjectHashTable.TableEntry<V> getAtIndexOpaque(SWMRLong2ObjectHashTable.TableEntry<V>[] table, int index) protected static intgetCapacityFor(int capacity) protected final SWMRLong2ObjectHashTable.TableEntry<V> getEntryForOpaque(long key) Callers must still use acquire when reading the value of the entry.protected final SWMRLong2ObjectHashTable.TableEntry<V> getEntryForPlain(long key) protected static intgetHash(long key) must be deterministic given a keyfinal floatgetOrDefault(long key, V defaultValue) protected final intprotected final intprotected final intprotected final SWMRLong2ObjectHashTable.TableEntry<V>[]protected final SWMRLong2ObjectHashTable.TableEntry<V>[]protected static intgetTargetCapacity(int capacity, float loadFactor) inthashCode()booleanisEmpty()protected final VvoidputAll(SWMRLong2ObjectHashTable<? extends V> map) putIfAbsent(long key, V value) remove(long key) protected final Vremove(long key, int hash) protected final Vbooleanprotected final intremoveFromSize(int num) protected static <V> voidsetAtIndexRelease(SWMRLong2ObjectHashTable.TableEntry<V>[] table, int index, SWMRLong2ObjectHashTable.TableEntry<V> value) protected final voidsetSizeOpaque(int value) protected final voidsetSizePlain(int value) protected final voidsetSizeRelease(int value) protected final voidprotected final voidintsize()toString()
-
Field Details
-
size
protected int size -
table
-
loadFactor
protected final float loadFactor -
SIZE_HANDLE
-
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 of16and load factor of0.75f. -
SWMRLong2ObjectHashTable
public SWMRLong2ObjectHashTable(int capacity) Constructs this map with the specified capacity and load factor of0.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, > 0loadFactor- specified load factor,> 0 && finite
-
SWMRLong2ObjectHashTable
Constructs this map with a capacity of16or the specified map's size, whichever is larger, and with a load factor of0.75f. All of the specified map's entries are copied into this map.- Parameters:
other- The specified map.
-
SWMRLong2ObjectHashTable
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 of0.75f. All of the specified map's entries are copied into this map.- Parameters:
capacity- specified capacity, > 0other- The specified map.
-
SWMRLong2ObjectHashTable
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, > 0loadFactor- specified load factor,> 0 && finiteother- 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
-
getTableAcquire
-
setTablePlain
-
setTableRelease
-
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
Callers must still use acquire when reading the value of the entry. -
getEntryForPlain
-
getHash
protected static int getHash(long key) must be deterministic given a key -
getTargetCapacity
protected static int getTargetCapacity(int capacity, float loadFactor) -
equals
-
hashCode
public int hashCode() -
toString
-
clone
-
forEach
-
forEach
-
forEachKey
Provides the specified consumer with all keys contained within this map.- Parameters:
action- The specified consumer.
-
forEachValue
Provides the specified consumer with all values contained within this map. Equivalent tomap.values().forEach(Consumer).- Parameters:
action- The specified consumer.
-
get
-
containsKey
public boolean containsKey(long key) -
getOrDefault
-
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
-
put
-
putIfAbsent
-
remove
-
remove
-
remove
-
remove
-
putAll
-
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.
-