Package com.google.common.collect
Class RegularImmutableMap<K,V>
- java.lang.Object
-
- com.google.common.collect.ImmutableMap<K,V>
-
- com.google.common.collect.RegularImmutableMap<K,V>
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Map<K,V>
final class RegularImmutableMap<K,V> extends ImmutableMap<K,V>
Implementation ofImmutableMap
with two or more entries.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RegularImmutableMap.KeySet<K>
private static class
RegularImmutableMap.Values<K,V>
-
Nested classes/interfaces inherited from class com.google.common.collect.ImmutableMap
ImmutableMap.Builder<K,V>, ImmutableMap.IteratorBasedImmutableMap<K,V>, ImmutableMap.SerializedForm<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static ImmutableMap<java.lang.Object,java.lang.Object>
EMPTY
(package private) java.util.Map.Entry<K,V>[]
entries
(package private) static double
HASH_FLOODING_FPP
Maximum allowed false positive probability of detecting a hash flooding attack given random input.private int
mask
(package private) static int
MAX_HASH_BUCKET_LENGTH
Maximum allowed length of a hash table bucket before falling back to a j.u.HashMap based implementation.(package private) static double
MAX_LOAD_FACTOR
Closed addressing tends to perform well even with high load factors.private static long
serialVersionUID
private ImmutableMapEntry<K,V>[]
table
-
Fields inherited from class com.google.common.collect.ImmutableMap
EMPTY_ENTRY_ARRAY
-
-
Constructor Summary
Constructors Modifier Constructor Description private
RegularImmutableMap(java.util.Map.Entry<K,V>[] entries, ImmutableMapEntry<K,V>[] table, int mask)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static int
checkNoConflictInKeyBucket(java.lang.Object key, java.util.Map.Entry<?,?> entry, ImmutableMapEntry<?,?> keyBucketHead)
(package private) ImmutableSet<java.util.Map.Entry<K,V>>
createEntrySet()
(package private) ImmutableSet<K>
createKeySet()
(package private) ImmutableCollection<V>
createValues()
void
forEach(java.util.function.BiConsumer<? super K,? super V> action)
(package private) static <K,V>
ImmutableMap<K,V>fromEntries(java.util.Map.Entry<K,V>... entries)
(package private) static <K,V>
ImmutableMap<K,V>fromEntryArray(int n, java.util.Map.Entry<K,V>[] entryArray)
Creates an ImmutableMap from the first n entries in entryArray.V
get(java.lang.Object key)
(package private) static <V> V
get(java.lang.Object key, ImmutableMapEntry<?,V>[] keyTable, int mask)
(package private) boolean
isPartialView()
(package private) static <K,V>
ImmutableMapEntry<K,V>makeImmutable(java.util.Map.Entry<K,V> entry)
Makes an entry usable internally by a new ImmutableMap.(package private) static <K,V>
ImmutableMapEntry<K,V>makeImmutable(java.util.Map.Entry<K,V> entry, K key, V value)
Makes an entry usable internally by a new ImmutableMap without rereading its contents.int
size()
-
Methods inherited from class com.google.common.collect.ImmutableMap
asMultimap, builder, builderWithExpectedSize, checkNoConflict, clear, compute, computeIfAbsent, computeIfPresent, conflictException, containsKey, containsValue, copyOf, copyOf, entryOf, entrySet, equals, getOrDefault, hashCode, isEmpty, isHashCodeFast, keyIterator, keySet, keySpliterator, merge, of, of, of, of, of, of, of, of, of, of, of, ofEntries, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, toImmutableMap, toImmutableMap, toString, values, writeReplace
-
-
-
-
Field Detail
-
EMPTY
static final ImmutableMap<java.lang.Object,java.lang.Object> EMPTY
-
MAX_LOAD_FACTOR
static final double MAX_LOAD_FACTOR
Closed addressing tends to perform well even with high load factors. Being conservative here ensures that the table is still likely to be relatively sparse (hence it misses fast) while saving space.- See Also:
- Constant Field Values
-
HASH_FLOODING_FPP
static final double HASH_FLOODING_FPP
Maximum allowed false positive probability of detecting a hash flooding attack given random input.- See Also:
- Constant Field Values
-
MAX_HASH_BUCKET_LENGTH
static final int MAX_HASH_BUCKET_LENGTH
Maximum allowed length of a hash table bucket before falling back to a j.u.HashMap based implementation. Experimentally determined.- See Also:
- Constant Field Values
-
table
@CheckForNull private final transient ImmutableMapEntry<K,V>[] table
-
mask
private final transient int mask
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RegularImmutableMap
private RegularImmutableMap(java.util.Map.Entry<K,V>[] entries, @CheckForNull ImmutableMapEntry<K,V>[] table, int mask)
-
-
Method Detail
-
fromEntries
static <K,V> ImmutableMap<K,V> fromEntries(java.util.Map.Entry<K,V>... entries)
-
fromEntryArray
static <K,V> ImmutableMap<K,V> fromEntryArray(int n, java.util.Map.Entry<K,V>[] entryArray)
Creates an ImmutableMap from the first n entries in entryArray. This implementation may replace the entries in entryArray with its own entry objects (though they will have the same key/value contents), and may take ownership of entryArray.
-
makeImmutable
static <K,V> ImmutableMapEntry<K,V> makeImmutable(java.util.Map.Entry<K,V> entry, K key, V value)
Makes an entry usable internally by a new ImmutableMap without rereading its contents.
-
makeImmutable
static <K,V> ImmutableMapEntry<K,V> makeImmutable(java.util.Map.Entry<K,V> entry)
Makes an entry usable internally by a new ImmutableMap.
-
checkNoConflictInKeyBucket
static int checkNoConflictInKeyBucket(java.lang.Object key, java.util.Map.Entry<?,?> entry, @CheckForNull ImmutableMapEntry<?,?> keyBucketHead)
- Returns:
- number of entries in this bucket
- Throws:
java.lang.IllegalArgumentException
- if another entry in the bucket has the same key
-
get
@CheckForNull public V get(@CheckForNull java.lang.Object key)
-
get
@CheckForNull static <V> V get(@CheckForNull java.lang.Object key, @CheckForNull ImmutableMapEntry<?,V>[] keyTable, int mask)
-
size
public int size()
-
isPartialView
boolean isPartialView()
- Specified by:
isPartialView
in classImmutableMap<K,V>
-
createEntrySet
ImmutableSet<java.util.Map.Entry<K,V>> createEntrySet()
- Specified by:
createEntrySet
in classImmutableMap<K,V>
-
createKeySet
ImmutableSet<K> createKeySet()
- Specified by:
createKeySet
in classImmutableMap<K,V>
-
createValues
ImmutableCollection<V> createValues()
- Specified by:
createValues
in classImmutableMap<K,V>
-
-