Top Description Inners Fields Constructors Methods
com.google.common.collect

pack-priv final Class JdkBackedImmutableBiMap<K, V>

extends ImmutableBiMap<K, V>
Class Inheritance
Annotations
@GwtCompatible
emulated:true
@ElementTypesAreNonnullByDefault
Static Imports
java.util.Objects.requireNonNull

Implementation of ImmutableBiMap backed by a pair of JDK HashMaps, which have smartness protecting against hash flooding.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Map<V, K>
private final transient ImmutableList<Map.Entry<K, V>>
private final Map<K, V>
private transient JdkBackedImmutableBiMap<V, K>

Constructor Summary

AccessConstructor and Description
private
JdkBackedImmutableBiMap(ImmutableList<Map.Entry<K, V>> entries, Map<K, V> forwardDelegate, Map<V, K> backwardDelegate)

Method Summary

Modifier and TypeMethod and Description
pack-priv static <K, V> ImmutableBiMap<K, V>
create(int n, @Nullable Map.Entry<K, V>[] entryArray)

pack-priv ImmutableSet<Map.Entry<K, V>>
pack-priv ImmutableSet<K>
public V
get(Object
the key whose associated value is to be returned
key
)

Implements abstract com.google.common.collect.ImmutableMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
public ImmutableBiMap<V, K>
inverse()

Implements abstract com.google.common.collect.ImmutableBiMap.inverse.

Implements com.google.common.collect.BiMap.inverse.

Returns the inverse view of this bimap, which maps each of this bimap's values to its associated key.
pack-priv boolean
public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
Inherited from com.google.common.collect.ImmutableBiMap:
builderbuilderWithExpectedSizecopyOfcopyOfcreateValuesforcePutofofofofofofofofofofofofEntriestoImmutableBiMapvalueswriteReplace

Field Detail

backwardDelegateback to summary
private final Map<V, K> backwardDelegate
entriesback to summary
private final transient ImmutableList<Map.Entry<K, V>> entries
forwardDelegateback to summary
private final Map<K, V> forwardDelegate
inverseback to summary
private transient JdkBackedImmutableBiMap<V, K> inverse
Annotations
@LazyInit
@RetainedWith
@CheckForNull

Constructor Detail

JdkBackedImmutableBiMapback to summary
private JdkBackedImmutableBiMap(ImmutableList<Map.Entry<K, V>> entries, Map<K, V> forwardDelegate, Map<V, K> backwardDelegate)

Method Detail

createback to summary
pack-priv static <K, V> ImmutableBiMap<K, V> create(int n, @Nullable Map.Entry<K, V>[] entryArray)
Annotations
@VisibleForTesting
createEntrySetback to summary
pack-priv ImmutableSet<Map.Entry<K, V>> createEntrySet()

Implements abstract com.google.common.collect.ImmutableMap.createEntrySet.

Annotations
@Override
createKeySetback to summary
pack-priv ImmutableSet<K> createKeySet()

Implements abstract com.google.common.collect.ImmutableMap.createKeySet.

Annotations
@Override
getback to summary
public V get(Object key)

Implements abstract com.google.common.collect.ImmutableMap.get.

Implements java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:Object

the key whose associated value is to be returned

Returns:V

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
@CheckForNull
inverseback to summary
public ImmutableBiMap<V, K> inverse()

Implements abstract com.google.common.collect.ImmutableBiMap.inverse.

Implements com.google.common.collect.BiMap.inverse.

Doc from com.google.common.collect.ImmutableBiMap.inverse.

Returns the inverse view of this bimap, which maps each of this bimap's values to its associated key. The two bimaps are backed by the same data; any changes to one will appear in the other.

Note

There is no guaranteed correspondence between the iteration order of a bimap and that of its inverse.

The inverse of an ImmutableBiMap is another ImmutableBiMap.

Returns:ImmutableBiMap<V, K>

Doc from com.google.common.collect.BiMap.inverse.

the inverse view of this bimap

Annotations
@Override
isPartialViewback to summary
pack-priv boolean isPartialView()

Implements abstract com.google.common.collect.ImmutableMap.isPartialView.

Annotations
@Override
sizeback to summary
public int size()

Implements java.util.Map.size.

Doc from java.util.Map.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of key-value mappings in this map

Annotations
@Override
com.google.common.collect back to summary

private final Class JdkBackedImmutableBiMap.InverseEntries

extends ImmutableList<Map.Entry<V, K>>
Class Inheritance
Annotations
@WeakOuter

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Map.Entry<V, K>
get(int
index of the element to return
index
)

Implements java.util.List.get.

Returns the element at the specified position in this list.
pack-priv boolean
isPartialView()

Implements abstract com.google.common.collect.ImmutableCollection.isPartialView.

Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods.
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.
Inherited from com.google.common.collect.ImmutableList:
addaddAllasImmutableListasImmutableListasListbuilderbuilderWithExpectedSizecontainscopyIntoArraycopyOfcopyOfcopyOfcopyOfequalsforEachhashCodeindexOfiteratorlastIndexOflistIteratorlistIteratorofofofofofofofofofofofofofremovereplaceAllreversesetsortsortedCopyOfsortedCopyOfspliteratorsubListsubListUncheckedtoImmutableListwriteReplace

Constructor Detail

InverseEntriesback to summary
private InverseEntries()

Method Detail

getback to summary
public Map.Entry<V, K> get(int index)

Implements java.util.List.get.

Doc from java.util.List.get.

Returns the element at the specified position in this list.

Parameters
index:int

index of the element to return

Returns:Map.Entry<V, K>

the element at the specified position in this list

Annotations
@Override
isPartialViewback to summary
pack-priv boolean isPartialView()

Implements abstract com.google.common.collect.ImmutableCollection.isPartialView.

Doc from com.google.common.collect.ImmutableCollection.isPartialView.

Returns true if this immutable collection's implementation contains references to user-created objects that aren't accessible via this collection's methods. This is generally used to determine whether copyOf implementations should make an explicit copy to avoid memory leaks.

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

Annotations
@Override