public final class BiMap<K,V>
extends java.lang.Object
implements java.util.Map<K,V>
Constructor and Description |
---|
BiMap() |
BiMap(java.lang.Class<? extends java.util.Map> keyMapType,
java.lang.Class<? extends java.util.Map> valueMapType) |
BiMap(int initialCapacity) |
BiMap(int initialCapacity,
float loadFactor) |
BiMap(Supplier<? extends java.util.Map<K,V>> keyMapSupplier,
Supplier<? extends java.util.Map<V,K>> valueMapSupplier) |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
BiMap<K,V> |
copy() |
static <K,V> BiMap<K,V> |
copyOf(java.util.Map<? extends K,? extends V> map) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Returns an immutable Set of Immutable entry.
|
boolean |
equals(java.lang.Object obj) |
V |
forcePut(K key,
V value)
An alternate form of
put that silently removes any existing entry
with the value value before proceeding with the put(K, V)
operation. |
static <K,V> BiMap<K,V> |
from(java.util.Map<? extends K,? extends V> map)
Deprecated.
replaced by
copyOf |
V |
get(java.lang.Object key) |
K |
getByValue(java.lang.Object value) |
int |
hashCode() |
BiMap<V,K> |
inversed()
Returns the inverse view of this BiMap, which maps each of this bimap's values to its associated key.
|
boolean |
isEmpty() |
java.util.Set<K> |
keySet()
Returns an immutable key set.
|
static <K,V,k extends K,v extends V> |
of(k k1,
v v1) |
static <K,V,k extends K,v extends V> |
of(k k1,
v v1,
k k2,
v v2) |
static <K,V,k extends K,v extends V> |
of(k k1,
v v1,
k k2,
v v2,
k k3,
v v3) |
static <K,V,k extends K,v extends V> |
of(k k1,
v v1,
k k2,
v v2,
k k3,
v v3,
k k4,
v v4) |
static <K,V,k extends K,v extends V> |
of(k k1,
v v1,
k k2,
v v2,
k k3,
v v3,
k k4,
v v4,
k k5,
v v5) |
static <K,V,k extends K,v extends V> |
of(k k1,
v v1,
k k2,
v v2,
k k3,
v v3,
k k4,
v v4,
k k5,
v v5,
k k6,
v v6) |
static <K,V,k extends K,v extends V> |
of(k k1,
v v1,
k k2,
v v2,
k k3,
v v3,
k k4,
v v4,
k k5,
v v5,
k k6,
v v6,
k k7,
v v7) |
V |
put(K key,
V value) |
void |
putAll(java.util.Map<? extends K,? extends V> m)
Warning: the results of calling this method may vary depending on
the iteration order of
map . |
V |
remove(java.lang.Object key) |
K |
removeByValue(java.lang.Object value) |
int |
size() |
java.lang.String |
toString() |
java.util.Set<V> |
values()
Returns an immutable value set.
|
public BiMap()
public BiMap(int initialCapacity)
public BiMap(int initialCapacity, float loadFactor)
public BiMap(java.lang.Class<? extends java.util.Map> keyMapType, java.lang.Class<? extends java.util.Map> valueMapType)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1, k k2, v v2)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1, k k2, v v2, k k3, v v3)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1, k k2, v v2, k k3, v v3, k k4, v v4)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1, k k2, v v2, k k3, v v3, k k4, v v4, k k5, v v5)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1, k k2, v v2, k k3, v v3, k k4, v v4, k k5, v v5, k k6, v v6)
public static <K,V,k extends K,v extends V> BiMap<K,V> of(k k1, v v1, k k2, v v2, k k3, v v3, k k4, v v4, k k5, v v5, k k6, v v6, k k7, v v7)
public static <K,V> BiMap<K,V> copyOf(java.util.Map<? extends K,? extends V> map)
@Deprecated public static <K,V> BiMap<K,V> from(java.util.Map<? extends K,? extends V> map)
copyOf
map
- public K getByValue(java.lang.Object value)
public V put(K key, V value)
put
in interface java.util.Map<K,V>
java.lang.IllegalArgumentException
- if the given value is already bound to a
different key in this bimap. The bimap will remain unmodified in this
event. To avoid this exception, call forcePut(K, V)
instead.public V forcePut(K key, V value)
put
that silently removes any existing entry
with the value value
before proceeding with the put(K, V)
operation. If the bimap previously contained the provided key-value
mapping, this method has no effect.
Note that a successful call to this method could cause the size of the bimap to increase by one, stay the same, or even decrease by one.
Warning: If an existing entry with this value is removed, the key for that entry is discarded and not returned.
key
- the key with which the specified value is to be associatedvalue
- the value to be associated with the specified keynull
, or null
if there was no previous entrypublic void putAll(java.util.Map<? extends K,? extends V> m)
Warning: the results of calling this method may vary depending on
the iteration order of map
.
public K removeByValue(java.lang.Object value)
public boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public java.util.Set<K> keySet()
public java.util.Set<V> values()
public java.util.Set<java.util.Map.Entry<K,V>> entrySet()
public BiMap<V,K> inversed()
public int hashCode()
public boolean equals(java.lang.Object obj)
public java.lang.String toString()
toString
in class java.lang.Object