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:
Serializable
,Map<K,
V>
Implementation of
ImmutableMap
with two or more entries.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private static final class
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
FieldsModifier and TypeFieldDescription(package private) static final ImmutableMap<Object,
Object> (package private) static final double
Maximum allowed false positive probability of detecting a hash flooding attack given random input.private final int
(package private) static final int
Maximum allowed length of a hash table bucket before falling back to a j.u.HashMap based implementation.(package private) static final double
Closed addressing tends to perform well even with high load factors.private static final long
private final ImmutableMapEntry<K,
V>[] Fields inherited from class com.google.common.collect.ImmutableMap
EMPTY_ENTRY_ARRAY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
RegularImmutableMap
(Map.Entry<K, V>[] entries, ImmutableMapEntry<K, V>[] table, int mask) -
Method Summary
Modifier and TypeMethodDescription(package private) static int
checkNoConflictInKeyBucket
(Object key, Map.Entry<?, ?> entry, ImmutableMapEntry<?, ?> keyBucketHead) (package private) ImmutableSet<Map.Entry<K,
V>> (package private) ImmutableSet<K>
(package private) ImmutableCollection<V>
void
forEach
(BiConsumer<? super K, ? super V> action) (package private) static <K,
V> ImmutableMap<K, V> fromEntries
(Map.Entry<K, V>... entries) (package private) static <K,
V> ImmutableMap<K, V> fromEntryArray
(int n, Map.Entry<K, V>[] entryArray) Creates an ImmutableMap from the first n entries in entryArray.(package private) static <V> V
get
(Object key, ImmutableMapEntry<?, V>[] keyTable, int mask) (package private) boolean
(package private) static <K,
V> ImmutableMapEntry<K, V> makeImmutable
(Map.Entry<K, V> entry) Makes an entry usable internally by a new ImmutableMap.(package private) static <K,
V> ImmutableMapEntry<K, V> makeImmutable
(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 Details
-
EMPTY
-
MAX_LOAD_FACTOR
static final double MAX_LOAD_FACTORClosed 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:
-
HASH_FLOODING_FPP
static final double HASH_FLOODING_FPPMaximum allowed false positive probability of detecting a hash flooding attack given random input.- See Also:
-
MAX_HASH_BUCKET_LENGTH
static final int MAX_HASH_BUCKET_LENGTHMaximum allowed length of a hash table bucket before falling back to a j.u.HashMap based implementation. Experimentally determined.- See Also:
-
entries
-
table
-
mask
private final transient int mask -
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
RegularImmutableMap
-
-
Method Details
-
fromEntries
-
fromEntryArray
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
Makes an entry usable internally by a new ImmutableMap without rereading its contents. -
makeImmutable
Makes an entry usable internally by a new ImmutableMap. -
checkNoConflictInKeyBucket
static int checkNoConflictInKeyBucket(Object key, Map.Entry<?, ?> entry, @CheckForNull ImmutableMapEntry<?, ?> keyBucketHead) - Returns:
- number of entries in this bucket
- Throws:
IllegalArgumentException
- if another entry in the bucket has the same key
-
get
-
get
@CheckForNull static <V> V get(@CheckForNull Object key, @CheckForNull ImmutableMapEntry<?, V>[] keyTable, int mask) -
forEach
-
size
public int size() -
isPartialView
boolean isPartialView()- Specified by:
isPartialView
in classImmutableMap<K,
V>
-
createEntrySet
ImmutableSet<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>
-