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 class
ConcurrentIntObjectHashMap.HashIterator
private static class
ConcurrentIntObjectHashMap.IntHashEntry<V>
private static class
ConcurrentIntObjectHashMap.SimpleEntry<V>
private class
ConcurrentIntObjectHashMap.ValueIterator
-
Field Summary
Fields Modifier and Type Field Description private float
_loadFactor
private byte
_lockIndex
protected int
count
protected static int
DEFAULT_INITIAL_CAPACITY
protected static float
DEFAULT_LOAD_FACTOR
protected static int
MAXIMUM_CAPACITY
protected int
modCount
private static StripedReentrantLock
STRIPED_REENTRANT_LOCK
protected 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 V
addOrGet(int key, V value)
void
clear()
private static int
computeInitialCapacity(int initialCapacity, float loadFactor)
boolean
contains(int key)
java.lang.Iterable<V>
elements()
java.lang.Iterable<IntObjectEntry<V>>
entries()
V
get(int key)
private ConcurrentIntObjectHashMap.IntHashEntry<V>
getFirst(int hash)
boolean
isEmpty()
int[]
keys()
private void
lock()
V
put(int key, V value)
protected V
put(int key, V value, boolean onlyIfAbsent)
V
putIfAbsent(int key, V value)
private V
readValueUnderLock(ConcurrentIntObjectHashMap.IntHashEntry<V> entry)
Read the value of an entry under lock.private void
rehash()
V
remove(int key)
boolean
remove(int key, V value)
protected V
removeCore(int key, V value)
boolean
replace(int key, V oldValue, V newValue)
private void
setTable(ConcurrentIntObjectHashMap.IntHashEntry<?>[] newTable)
int
size()
private int
threshold()
private void
unlock()
-
-
-
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:
addOrGet
in interfaceConcurrentIntObjectMap<V>
-
remove
public boolean remove(int key, @NotNull V value)
- Specified by:
remove
in interfaceConcurrentIntObjectMap<V>
-
replace
public boolean replace(int key, @NotNull V oldValue, @NotNull V newValue)
- Specified by:
replace
in interfaceConcurrentIntObjectMap<V>
-
put
public V put(int key, @NotNull V value)
- Specified by:
put
in interfaceConcurrentIntObjectMap<V>
-
putIfAbsent
public V putIfAbsent(int key, @NotNull V value)
- Specified by:
putIfAbsent
in interfaceConcurrentIntObjectMap<V>
-
get
public V get(int key)
- Specified by:
get
in interfaceConcurrentIntObjectMap<V>
-
remove
public V remove(int key)
- Specified by:
remove
in interfaceConcurrentIntObjectMap<V>
-
size
public int size()
- Specified by:
size
in interfaceConcurrentIntObjectMap<V>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceConcurrentIntObjectMap<V>
-
contains
public boolean contains(int key)
- Specified by:
contains
in interfaceConcurrentIntObjectMap<V>
-
clear
public void clear()
- Specified by:
clear
in interfaceConcurrentIntObjectMap<V>
-
keys
@NotNull public int[] keys()
- Specified by:
keys
in interfaceConcurrentIntObjectMap<V>
-
entries
@NotNull public java.lang.Iterable<IntObjectEntry<V>> entries()
- Specified by:
entries
in interfaceConcurrentIntObjectMap<V>
-
-