K
- the type of the keys in the mapV
- the type of the values in the mapE
- the type of the MapMakerInternalMap.InternalEntry
entry implementation used internallyS
- the type of the MapMakerInternalMap.Segment
entry implementation used internally@GwtIncompatible class MapMakerInternalMap<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>,S extends MapMakerInternalMap.Segment<K,V,E,S>> extends java.util.AbstractMap<K,V> implements java.util.concurrent.ConcurrentMap<K,V>, java.io.Serializable
MapMaker
.
This implementation is heavily derived from revision 1.96 of ConcurrentHashMap.java.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
MapMakerInternalMap.AbstractSerializationProxy<K,V>
The actual object that gets serialized.
|
(package private) static class |
MapMakerInternalMap.AbstractStrongKeyEntry<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
Base class for
MapMakerInternalMap.InternalEntry implementations for strong keys. |
(package private) static class |
MapMakerInternalMap.AbstractWeakKeyEntry<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
Base class for
MapMakerInternalMap.InternalEntry implementations for weak keys. |
(package private) static class |
MapMakerInternalMap.CleanupMapTask |
(package private) static class |
MapMakerInternalMap.DummyInternalEntry
A dummy implementation of
MapMakerInternalMap.InternalEntry , solely for use in the type signature of UNSET_WEAK_VALUE_REFERENCE below. |
(package private) class |
MapMakerInternalMap.EntryIterator |
(package private) class |
MapMakerInternalMap.EntrySet |
(package private) class |
MapMakerInternalMap.HashIterator<T> |
(package private) static interface |
MapMakerInternalMap.InternalEntry<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
An entry in a hash table of a
MapMakerInternalMap.Segment . |
(package private) static interface |
MapMakerInternalMap.InternalEntryHelper<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>,S extends MapMakerInternalMap.Segment<K,V,E,S>>
A helper object for operating on
MapMakerInternalMap.InternalEntry instances in a type-safe and efficient
manner. |
(package private) class |
MapMakerInternalMap.KeyIterator |
(package private) class |
MapMakerInternalMap.KeySet |
private static class |
MapMakerInternalMap.SafeToArraySet<E> |
(package private) static class |
MapMakerInternalMap.Segment<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>,S extends MapMakerInternalMap.Segment<K,V,E,S>>
Segments are specialized versions of hash tables.
|
private static class |
MapMakerInternalMap.SerializationProxy<K,V>
The actual object that gets serialized.
|
(package private) static class |
MapMakerInternalMap.Strength |
(package private) static class |
MapMakerInternalMap.StrongKeyStrongValueEntry<K,V>
Concrete implementation of
MapMakerInternalMap.InternalEntry for strong keys and strong values. |
(package private) static class |
MapMakerInternalMap.StrongKeyStrongValueSegment<K,V>
Concrete implementation of
MapMakerInternalMap.Segment for strong keys and strong values. |
(package private) static class |
MapMakerInternalMap.StrongKeyWeakValueEntry<K,V>
Concrete implementation of
MapMakerInternalMap.InternalEntry for strong keys and weak values. |
(package private) static class |
MapMakerInternalMap.StrongKeyWeakValueSegment<K,V>
Concrete implementation of
MapMakerInternalMap.Segment for strong keys and weak values. |
(package private) static interface |
MapMakerInternalMap.StrongValueEntry<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
Marker interface for
MapMakerInternalMap.InternalEntry implementations for strong values. |
(package private) class |
MapMakerInternalMap.ValueIterator |
(package private) class |
MapMakerInternalMap.Values |
(package private) static class |
MapMakerInternalMap.WeakKeyStrongValueEntry<K,V>
Concrete implementation of
MapMakerInternalMap.InternalEntry for weak keys and strong values. |
(package private) static class |
MapMakerInternalMap.WeakKeyStrongValueSegment<K,V>
Concrete implementation of
MapMakerInternalMap.Segment for weak keys and strong values. |
(package private) static class |
MapMakerInternalMap.WeakKeyWeakValueEntry<K,V>
Concrete implementation of
MapMakerInternalMap.InternalEntry for weak keys and weak values. |
(package private) static class |
MapMakerInternalMap.WeakKeyWeakValueSegment<K,V>
Concrete implementation of
MapMakerInternalMap.Segment for weak keys and weak values. |
(package private) static interface |
MapMakerInternalMap.WeakValueEntry<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
Marker interface for
MapMakerInternalMap.InternalEntry implementations for weak values. |
(package private) static interface |
MapMakerInternalMap.WeakValueReference<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
A weakly referenced value that also has a reference to its containing entry.
|
(package private) static class |
MapMakerInternalMap.WeakValueReferenceImpl<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>>
Concrete implementation of
MapMakerInternalMap.WeakValueReference . |
(package private) class |
MapMakerInternalMap.WriteThroughEntry
Custom Entry class used by EntryIterator.next(), that relays setValue changes to the
underlying map.
|
Modifier and Type | Field and Description |
---|---|
(package private) static long |
CLEANUP_EXECUTOR_DELAY_SECS |
(package private) int |
concurrencyLevel
The concurrency level.
|
(package private) static int |
CONTAINS_VALUE_RETRIES
Number of (unsynchronized) retries in the containsValue method.
|
(package private) static int |
DRAIN_MAX
Maximum number of entries to be drained in a single cleanup run.
|
(package private) static int |
DRAIN_THRESHOLD
Number of cache access operations that can be buffered per segment before the cache's recency
ordering information is updated.
|
(package private) MapMakerInternalMap.InternalEntryHelper<K,V,E,S> |
entryHelper
Strategy for handling entries and segments in a type-safe and efficient manner.
|
(package private) java.util.Set<java.util.Map.Entry<K,V>> |
entrySet |
(package private) Equivalence<java.lang.Object> |
keyEquivalence
Strategy for comparing keys.
|
(package private) java.util.Set<K> |
keySet |
(package private) static int |
MAX_SEGMENTS
The maximum number of segments to allow; used to bound constructor arguments.
|
(package private) static int |
MAXIMUM_CAPACITY
The maximum capacity, used if a higher value is implicitly specified by either of the
constructors with arguments.
|
(package private) int |
segmentMask
Mask value for indexing into segments.
|
(package private) MapMakerInternalMap.Segment<K,V,E,S>[] |
segments
The segments, each of which is a specialized hash table.
|
(package private) int |
segmentShift
Shift value for indexing within segments.
|
private static long |
serialVersionUID |
(package private) static MapMakerInternalMap.WeakValueReference<java.lang.Object,java.lang.Object,MapMakerInternalMap.DummyInternalEntry> |
UNSET_WEAK_VALUE_REFERENCE
A singleton
MapMakerInternalMap.WeakValueReference used to denote an unset value in a entry with weak
values. |
(package private) java.util.Collection<V> |
values |
Modifier | Constructor and Description |
---|---|
private |
MapMakerInternalMap(MapMaker builder,
MapMakerInternalMap.InternalEntryHelper<K,V,E,S> entryHelper)
Creates a new, empty map with the specified strategy, initial capacity and concurrency level.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
(package private) E |
copyEntry(E original,
E newNext)
This method is a convenience for testing.
|
(package private) static <K,V> MapMakerInternalMap<K,V,? extends MapMakerInternalMap.InternalEntry<K,V,?>,?> |
create(MapMaker builder) |
(package private) MapMakerInternalMap.Segment<K,V,E,S> |
createSegment(int initialCapacity,
int maxSegmentSize) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
V |
get(java.lang.Object key) |
(package private) E |
getEntry(java.lang.Object key)
Returns the internal entry for the specified key.
|
(package private) V |
getLiveValue(E entry)
Gets the value from an entry.
|
(package private) int |
hash(java.lang.Object key) |
boolean |
isEmpty() |
(package private) boolean |
isLiveForTesting(MapMakerInternalMap.InternalEntry<K,V,?> entry)
This method is a convenience for testing.
|
java.util.Set<K> |
keySet() |
(package private) MapMakerInternalMap.Strength |
keyStrength() |
(package private) MapMakerInternalMap.Segment<K,V,E,S>[] |
newSegmentArray(int ssize) |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
putIfAbsent(K key,
V value) |
(package private) void |
reclaimKey(E entry) |
(package private) void |
reclaimValue(MapMakerInternalMap.WeakValueReference<K,V,E> valueReference) |
(package private) static int |
rehash(int h)
Applies a supplemental hash function to a given hash code, which defends against poor quality
hash functions.
|
V |
remove(java.lang.Object key) |
boolean |
remove(java.lang.Object key,
java.lang.Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
(package private) MapMakerInternalMap.Segment<K,V,E,S> |
segmentFor(int hash)
Returns the segment that should be used for a key with the given hash.
|
int |
size() |
private static <E> java.util.ArrayList<E> |
toArrayList(java.util.Collection<E> c) |
(package private) static <K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>> |
unsetWeakValueReference() |
(package private) Equivalence<java.lang.Object> |
valueEquivalence() |
java.util.Collection<V> |
values() |
(package private) MapMakerInternalMap.Strength |
valueStrength() |
(package private) java.lang.Object |
writeReplace() |
finalize, getClass, notify, notifyAll, wait, wait, wait
static final int MAXIMUM_CAPACITY
static final int MAX_SEGMENTS
static final int CONTAINS_VALUE_RETRIES
static final int DRAIN_THRESHOLD
This must be a (2^n)-1 as it is used as a mask.
static final int DRAIN_MAX
static final long CLEANUP_EXECUTOR_DELAY_SECS
final transient int segmentMask
final transient int segmentShift
final transient MapMakerInternalMap.Segment<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>,S extends MapMakerInternalMap.Segment<K,V,E,S>>[] segments
final int concurrencyLevel
final Equivalence<java.lang.Object> keyEquivalence
final transient MapMakerInternalMap.InternalEntryHelper<K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>,S extends MapMakerInternalMap.Segment<K,V,E,S>> entryHelper
static final MapMakerInternalMap.WeakValueReference<java.lang.Object,java.lang.Object,MapMakerInternalMap.DummyInternalEntry> UNSET_WEAK_VALUE_REFERENCE
MapMakerInternalMap.WeakValueReference
used to denote an unset value in a entry with weak
values.transient java.util.Set<K> keySet
transient java.util.Collection<V> values
private static final long serialVersionUID
static <K,V> MapMakerInternalMap<K,V,? extends MapMakerInternalMap.InternalEntry<K,V,?>,?> create(MapMaker builder)
static <K,V,E extends MapMakerInternalMap.InternalEntry<K,V,E>> MapMakerInternalMap.WeakValueReference<K,V,E> unsetWeakValueReference()
static int rehash(int h)
h
- hash codeE copyEntry(E original, E newNext)
MapMakerInternalMap.Segment.copyEntry(E, E)
directly.int hash(java.lang.Object key)
void reclaimValue(MapMakerInternalMap.WeakValueReference<K,V,E> valueReference)
void reclaimKey(E entry)
boolean isLiveForTesting(MapMakerInternalMap.InternalEntry<K,V,?> entry)
MapMakerInternalMap.Segment.getLiveValue(E)
instead.MapMakerInternalMap.Segment<K,V,E,S> segmentFor(int hash)
hash
- the hash code for the keyMapMakerInternalMap.Segment<K,V,E,S> createSegment(int initialCapacity, int maxSegmentSize)
V getLiveValue(E entry)
null
if the entry is invalid, partially-collected
or computing.final MapMakerInternalMap.Segment<K,V,E,S>[] newSegmentArray(int ssize)
MapMakerInternalMap.Strength keyStrength()
MapMakerInternalMap.Strength valueStrength()
Equivalence<java.lang.Object> valueEquivalence()
public boolean isEmpty()
public int size()
public V get(@Nullable java.lang.Object key)
E getEntry(@Nullable java.lang.Object key)
public boolean containsKey(@Nullable java.lang.Object key)
public boolean containsValue(@Nullable java.lang.Object value)
public V remove(@Nullable java.lang.Object key)
public boolean remove(@Nullable java.lang.Object key, @Nullable java.lang.Object value)
public void clear()
public java.util.Set<K> keySet()
public java.util.Collection<V> values()
private static <E> java.util.ArrayList<E> toArrayList(java.util.Collection<E> c)
java.lang.Object writeReplace()