Class ConcurrentIntObjectHashMap<V>
- java.lang.Object
-
- com.strobel.collections.concurrent.ConcurrentIntObjectHashMap<V>
-
- All Implemented Interfaces:
ConcurrentIntObjectMap<V>
public class ConcurrentIntObjectHashMap<V> extends java.lang.Object implements ConcurrentIntObjectMap<V>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classConcurrentIntObjectHashMap.HashIteratorprivate static classConcurrentIntObjectHashMap.IntHashEntry<V>private static classConcurrentIntObjectHashMap.SimpleEntry<V>private classConcurrentIntObjectHashMap.ValueIterator
-
Field Summary
Fields Modifier and Type Field Description private float_loadFactorprivate byte_lockIndexprotected intcountprotected static intDEFAULT_INITIAL_CAPACITYprotected static floatDEFAULT_LOAD_FACTORprotected static intMAXIMUM_CAPACITYprotected intmodCountprivate static StripedReentrantLockSTRIPED_REENTRANT_LOCKprotected ConcurrentIntObjectHashMap.IntHashEntry<V>[]table
-
Constructor Summary
Constructors Constructor Description ConcurrentIntObjectHashMap()ConcurrentIntObjectHashMap(int initialCapacity)ConcurrentIntObjectHashMap(int initialCapacity, float loadFactor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VaddOrGet(int key, V value)voidclear()private static intcomputeInitialCapacity(int initialCapacity, float loadFactor)booleancontains(int key)java.lang.Iterable<V>elements()java.lang.Iterable<IntObjectEntry<V>>entries()Vget(int key)private ConcurrentIntObjectHashMap.IntHashEntry<V>getFirst(int hash)booleanisEmpty()int[]keys()private voidlock()Vput(int key, V value)protected Vput(int key, V value, boolean onlyIfAbsent)VputIfAbsent(int key, V value)private VreadValueUnderLock(ConcurrentIntObjectHashMap.IntHashEntry<V> entry)Read the value of an entry under lock.private voidrehash()Vremove(int key)booleanremove(int key, V value)protected VremoveCore(int key, V value)booleanreplace(int key, V oldValue, V newValue)private voidsetTable(ConcurrentIntObjectHashMap.IntHashEntry<?>[] newTable)intsize()private intthreshold()private voidunlock()
-
-
-
Field Detail
-
DEFAULT_INITIAL_CAPACITY
protected static final int DEFAULT_INITIAL_CAPACITY
- See Also:
- Constant Field Values
-
MAXIMUM_CAPACITY
protected static final int MAXIMUM_CAPACITY
- See Also:
- Constant Field Values
-
DEFAULT_LOAD_FACTOR
protected static final float DEFAULT_LOAD_FACTOR
- See Also:
- Constant Field Values
-
STRIPED_REENTRANT_LOCK
private static final StripedReentrantLock STRIPED_REENTRANT_LOCK
-
_lockIndex
private final byte _lockIndex
-
table
protected volatile ConcurrentIntObjectHashMap.IntHashEntry<V>[] table
-
count
protected volatile int count
-
modCount
protected int modCount
-
_loadFactor
private final float _loadFactor
-
-
Method Detail
-
lock
private void lock()
-
unlock
private void unlock()
-
threshold
private int threshold()
-
setTable
private void setTable(ConcurrentIntObjectHashMap.IntHashEntry<?>[] newTable)
-
computeInitialCapacity
private static int computeInitialCapacity(int initialCapacity, float loadFactor)
-
getFirst
private ConcurrentIntObjectHashMap.IntHashEntry<V> getFirst(int hash)
-
readValueUnderLock
private V readValueUnderLock(ConcurrentIntObjectHashMap.IntHashEntry<V> entry)
Read the value of an entry under lock. Called if the value field appears to benull.
-
rehash
private void rehash()
-
addOrGet
@NotNull public V addOrGet(int key, @NotNull V value)
- Specified by:
addOrGetin interfaceConcurrentIntObjectMap<V>
-
remove
public boolean remove(int key, @NotNull V value)- Specified by:
removein interfaceConcurrentIntObjectMap<V>
-
replace
public boolean replace(int key, @NotNull V oldValue, @NotNull V newValue)- Specified by:
replacein interfaceConcurrentIntObjectMap<V>
-
put
public V put(int key, @NotNull V value)
- Specified by:
putin interfaceConcurrentIntObjectMap<V>
-
putIfAbsent
public V putIfAbsent(int key, @NotNull V value)
- Specified by:
putIfAbsentin interfaceConcurrentIntObjectMap<V>
-
get
public V get(int key)
- Specified by:
getin interfaceConcurrentIntObjectMap<V>
-
remove
public V remove(int key)
- Specified by:
removein interfaceConcurrentIntObjectMap<V>
-
size
public int size()
- Specified by:
sizein interfaceConcurrentIntObjectMap<V>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceConcurrentIntObjectMap<V>
-
contains
public boolean contains(int key)
- Specified by:
containsin interfaceConcurrentIntObjectMap<V>
-
clear
public void clear()
- Specified by:
clearin interfaceConcurrentIntObjectMap<V>
-
keys
@NotNull public int[] keys()
- Specified by:
keysin interfaceConcurrentIntObjectMap<V>
-
entries
@NotNull public java.lang.Iterable<IntObjectEntry<V>> entries()
- Specified by:
entriesin interfaceConcurrentIntObjectMap<V>
-
-