Package org.jboss.marshalling.reflect
Class UnlockedHashMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.jboss.marshalling.reflect.UnlockedHashMap<K,V>
-
- Type Parameters:
K
- the key typeV
- 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
UnlockedHashMap.BranchIterator
(package private) class
UnlockedHashMap.EntryIterator
(package private) class
UnlockedHashMap.EntrySet
(package private) static class
UnlockedHashMap.Item<K,V>
(package private) class
UnlockedHashMap.KeyIterator
(package private) class
UnlockedHashMap.KeySet
(package private) class
UnlockedHashMap.RowIterator
(package private) static class
UnlockedHashMap.Table<K,V>
(package private) class
UnlockedHashMap.TableIterator
(package private) class
UnlockedHashMap.ValueIterator
(package private) class
UnlockedHashMap.Values
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_INITIAL_CAPACITY
private static float
DEFAULT_LOAD_FACTOR
private java.util.Set<java.util.Map.Entry<K,V>>
entrySet
private int
initialCapacity
private java.util.Set<K>
keySet
private float
loadFactor
private static int
MAXIMUM_CAPACITY
private static java.lang.Object
NONEXISTENT
A non-existent table entry (as opposed to anull
value).private static UnlockedHashMap.Item<?,?>[]
RESIZED
A row which has been resized into the new view.private static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<UnlockedHashMap.Table>
sizeUpdater
private UnlockedHashMap.Table<K,V>
table
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<UnlockedHashMap,UnlockedHashMap.Table>
tableUpdater
private java.util.Collection<V>
values
private static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<UnlockedHashMap.Item,java.lang.Object>
valueUpdater
-
Constructor Summary
Constructors Constructor Description UnlockedHashMap()
Construct a new instance.UnlockedHashMap(float loadFactor)
Construct a new instance.UnlockedHashMap(int initialCapacity)
Construct a new instance.UnlockedHashMap(int initialCapacity, float loadFactor)
Construct a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private UnlockedHashMap.Item<K,V>[]
addItem(UnlockedHashMap.Item<K,V>[] row, UnlockedHashMap.Item<K,V> newItem)
void
clear()
boolean
containsKey(java.lang.Object key)
private static <K,V>
UnlockedHashMap.Item<K,V>[]createRow(int length)
private static <K,V>
UnlockedHashMap.Item<K,V>[]createRow(UnlockedHashMap.Item<K,V> newItem)
private UnlockedHashMap.TableIterator
createRowIterator(UnlockedHashMap.Table<K,V> table, int rowIdx)
private V
doGet(UnlockedHashMap.Table<K,V> table, K key)
private V
doPut(K key, V value, boolean ifAbsent, UnlockedHashMap.Table<K,V> table)
private V
doRemove(K key, UnlockedHashMap.Table<K,V> table)
private boolean
doRemove(K key, V value, UnlockedHashMap.Table<K,V> table)
private boolean
doRemove(UnlockedHashMap.Item<K,V> item, UnlockedHashMap.Table<K,V> table)
private V
doReplace(K key, V value, UnlockedHashMap.Table<K,V> table)
private boolean
doReplace(K key, V oldValue, V newValue, UnlockedHashMap.Table<K,V> table)
java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
V
get(java.lang.Object key)
private static int
hashCode(java.lang.Object key)
java.util.Set<K>
keySet()
private static <V> V
nonexistent()
V
put(K key, V value)
V
putIfAbsent(K key, V value)
V
remove(java.lang.Object objectKey)
boolean
remove(java.lang.Object objectKey, java.lang.Object objectValue)
private static <K,V>
UnlockedHashMap.Item<K,V>[]remove(UnlockedHashMap.Item<K,V>[] row, int idx)
V
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
private void
resize(UnlockedHashMap.Table<K,V> origTable)
private static <K,V>
UnlockedHashMap.Item<K,V>[]resized()
int
size()
java.util.Collection<V>
values()
-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
DEFAULT_INITIAL_CAPACITY
private static final int DEFAULT_INITIAL_CAPACITY
- See Also:
- Constant Field Values
-
MAXIMUM_CAPACITY
private static final int MAXIMUM_CAPACITY
- See Also:
- Constant Field Values
-
DEFAULT_LOAD_FACTOR
private static final float DEFAULT_LOAD_FACTOR
- 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 anull
value).
-
table
private volatile UnlockedHashMap.Table<K,V> table
-
keySet
private final java.util.Set<K> keySet
-
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
-
tableUpdater
private static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<UnlockedHashMap,UnlockedHashMap.Table> tableUpdater
-
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 capacityloadFactor
- 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
-
addItem
private UnlockedHashMap.Item<K,V>[] addItem(UnlockedHashMap.Item<K,V>[] row, UnlockedHashMap.Item<K,V> newItem)
-
createRow
private static <K,V> UnlockedHashMap.Item<K,V>[] createRow(UnlockedHashMap.Item<K,V> newItem)
-
createRow
private static <K,V> UnlockedHashMap.Item<K,V>[] createRow(int length)
-
hashCode
private static int hashCode(java.lang.Object key)
-
resize
private void resize(UnlockedHashMap.Table<K,V> origTable)
-
remove
private static <K,V> UnlockedHashMap.Item<K,V>[] remove(UnlockedHashMap.Item<K,V>[] row, int idx)
-
remove
public boolean remove(java.lang.Object objectKey, java.lang.Object objectValue)
-
doRemove
private boolean doRemove(UnlockedHashMap.Item<K,V> item, UnlockedHashMap.Table<K,V> table)
-
doRemove
private boolean doRemove(K key, V value, UnlockedHashMap.Table<K,V> table)
-
remove
public V remove(java.lang.Object objectKey)
-
doRemove
private V doRemove(K key, UnlockedHashMap.Table<K,V> table)
-
nonexistent
private static <V> V nonexistent()
-
resized
private static <K,V> UnlockedHashMap.Item<K,V>[] resized()
-
doReplace
private boolean doReplace(K key, V oldValue, V newValue, UnlockedHashMap.Table<K,V> table)
-
size
public int size()
-
doGet
private V doGet(UnlockedHashMap.Table<K,V> table, K key)
-
containsKey
public boolean containsKey(java.lang.Object key)
-
get
public V get(java.lang.Object key)
-
clear
public void clear()
-
values
public java.util.Collection<V> values()
-
keySet
public java.util.Set<K> keySet()
-
createRowIterator
private UnlockedHashMap.TableIterator createRowIterator(UnlockedHashMap.Table<K,V> table, int rowIdx)
-
-