final class RegularImmutableMap<K,V> extends ImmutableMap<K,V>
ImmutableMap
with two or more entries.Modifier and Type | Class and Description |
---|---|
(package private) static class |
RegularImmutableMap.BucketOverflowException |
private static class |
RegularImmutableMap.KeySet<K> |
private static class |
RegularImmutableMap.Values<K,V> |
ImmutableMap.Builder<K,V>, ImmutableMap.IteratorBasedImmutableMap<K,V>, ImmutableMap.SerializedForm<K,V>
Modifier and Type | Field and 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 |
EMPTY_ENTRY_ARRAY
Modifier | Constructor and Description |
---|---|
private |
RegularImmutableMap(java.util.Map.Entry<K,V>[] entries,
ImmutableMapEntry<K,V>[] table,
int mask) |
Modifier and Type | Method and Description |
---|---|
(package private) static <K,V> ImmutableMapEntry<K,V> |
checkNoConflictInKeyBucket(java.lang.Object key,
java.lang.Object newValue,
ImmutableMapEntry<K,V> keyBucketHead,
boolean throwIfDuplicateKeys)
Checks if the given key already appears in the hash chain starting at
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,
boolean throwIfDuplicateKeys)
Creates an ImmutableMap from the first n entries in entryArray.
|
private static <K,V> ImmutableMap<K,V> |
fromEntryArrayCheckingBucketOverflow(int n,
java.util.Map.Entry<K,V>[] entryArray,
boolean throwIfDuplicateKeys) |
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.
|
(package private) static <K,V> java.util.Map.Entry<K,V>[] |
removeDuplicates(java.util.Map.Entry<K,V>[] entries,
int n,
int newN,
java.util.IdentityHashMap<java.util.Map.Entry<K,V>,java.lang.Boolean> duplicates)
Constructs a new entry array where each duplicated key from the original appears only once, at
its first position but with its final value.
|
int |
size() |
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
static final ImmutableMap<java.lang.Object,java.lang.Object> EMPTY
static final double MAX_LOAD_FACTOR
static final double HASH_FLOODING_FPP
static final int MAX_HASH_BUCKET_LENGTH
@CheckForNull private final transient ImmutableMapEntry<K,V>[] table
private final transient int mask
private static final long serialVersionUID
private RegularImmutableMap(java.util.Map.Entry<K,V>[] entries, @CheckForNull ImmutableMapEntry<K,V>[] table, int mask)
static <K,V> ImmutableMap<K,V> fromEntries(java.util.Map.Entry<K,V>... entries)
static <K,V> ImmutableMap<K,V> fromEntryArray(int n, java.util.Map.Entry<K,V>[] entryArray, boolean throwIfDuplicateKeys)
private static <K,V> ImmutableMap<K,V> fromEntryArrayCheckingBucketOverflow(int n, java.util.Map.Entry<K,V>[] entryArray, boolean throwIfDuplicateKeys) throws RegularImmutableMap.BucketOverflowException
static <K,V> java.util.Map.Entry<K,V>[] removeDuplicates(java.util.Map.Entry<K,V>[] entries, int n, int newN, java.util.IdentityHashMap<java.util.Map.Entry<K,V>,java.lang.Boolean> duplicates)
duplicates
map is modified.entries
- the original array of entries including duplicatesn
- the number of valid entries in entries
newN
- the expected number of entries once duplicates are removedduplicates
- a map of canonical Entry
objects for each duplicate key. This map
will be updated by the method, setting each value to false as soon as the Entry
has
been included in the new entry array.newN
entries where no key appears more than once.static <K,V> ImmutableMapEntry<K,V> makeImmutable(java.util.Map.Entry<K,V> entry, K key, V value)
static <K,V> ImmutableMapEntry<K,V> makeImmutable(java.util.Map.Entry<K,V> entry)
static <K,V> ImmutableMapEntry<K,V> checkNoConflictInKeyBucket(java.lang.Object key, java.lang.Object newValue, @CheckForNull ImmutableMapEntry<K,V> keyBucketHead, boolean throwIfDuplicateKeys) throws RegularImmutableMap.BucketOverflowException
keyBucketHead
. If
it does not, then null is returned. If it does, then if throwIfDuplicateKeys
is true an
IllegalArgumentException
is thrown, and otherwise the existing Entry
is
returned.java.lang.IllegalArgumentException
- if another entry in the bucket has the same key and throwIfDuplicateKeys
is trueRegularImmutableMap.BucketOverflowException
- if this bucket has too many entries, which may indicate a hash
flooding attack@CheckForNull public V get(@CheckForNull java.lang.Object key)
@CheckForNull static <V> V get(@CheckForNull java.lang.Object key, @CheckForNull ImmutableMapEntry<?,V>[] keyTable, int mask)
public int size()
boolean isPartialView()
isPartialView
in class ImmutableMap<K,V>
ImmutableSet<java.util.Map.Entry<K,V>> createEntrySet()
createEntrySet
in class ImmutableMap<K,V>
ImmutableSet<K> createKeySet()
createKeySet
in class ImmutableMap<K,V>
ImmutableCollection<V> createValues()
createValues
in class ImmutableMap<K,V>