K - the key typeV - the value typepublic final class BiMap<K,V> extends Object implements Map<K,V>
| Constructor and Description |
|---|
BiMap() |
BiMap(Class<? extends Map> keyMapType,
Class<? extends Map> valueMapType) |
BiMap(int initialCapacity) |
BiMap(int initialCapacity,
float loadFactor) |
BiMap(Supplier<? extends Map<K,V>> keyMapSupplier,
Supplier<? extends Map<V,K>> valueMapSupplier) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear.
|
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
BiMap<K,V> |
copy() |
static <K,V> BiMap<K,V> |
copyOf(Map<? extends K,? extends V> map) |
Set<Map.Entry<K,V>> |
entrySet()
Returns an immutable Set of Immutable entry.
|
boolean |
equals(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(Map<? extends K,? extends V> map)
Deprecated.
replaced by
copyOf |
V |
get(Object key) |
K |
getByValue(Object value)
Gets the by 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()
Checks if is empty.
|
ImmutableSet<K> |
keySet()
Returns an immutable key set.
|
static <K,V> BiMap<K,V> |
of(K k1,
V v1) |
static <K,V> BiMap<K,V> |
of(K k1,
V v1,
K k2,
V v2) |
static <K,V> BiMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3) |
static <K,V> BiMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4) |
static <K,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) |
static <K,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) |
static <K,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) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m)
Warning: the results of calling this method may vary depending on
the iteration order of
map. |
V |
remove(Object key) |
K |
removeByValue(Object value)
Removes the by value.
|
int |
size() |
String |
toString() |
ImmutableSet<V> |
values()
Returns an immutable value set.
|
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic BiMap()
public BiMap(int initialCapacity)
public BiMap(int initialCapacity,
float loadFactor)
public static <K,V> BiMap<K,V> of(K k1, V v1)
K - the key typeV - the value typek - v - k1 - v1 - public static <K,V> BiMap<K,V> of(K k1, V v1, K k2, V v2)
K - the key typeV - the value typek - v - k1 - v1 - k2 - v2 - public static <K,V> BiMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3)
K - the key typeV - the value typek - v - k1 - v1 - k2 - v2 - k3 - v3 - public static <K,V> BiMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4)
K - the key typeV - the value typek - v - k1 - v1 - k2 - v2 - k3 - v3 - k4 - v4 - public static <K,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 - the key typeV - the value typek - v - k1 - v1 - k2 - v2 - k3 - v3 - k4 - v4 - k5 - v5 - public static <K,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 - the key typeV - the value typek - v - k1 - v1 - k2 - v2 - k3 - v3 - k4 - v4 - k5 - v5 - k6 - v6 - public static <K,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)
K - the key typeV - the value typek - v - k1 - v1 - k2 - v2 - k3 - v3 - k4 - v4 - k5 - v5 - k6 - v6 - k7 - v7 - public static <K,V> BiMap<K,V> copyOf(Map<? extends K,? extends V> map)
K - the key typeV - the value typemap - @Deprecated public static <K,V> BiMap<K,V> from(Map<? extends K,? extends V> map)
copyOfK - the key typeV - the value typemap - public V put(K key, V value)
put in interface Map<K,V>key - value - 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(Map<? extends K,? extends V> m)
Warning: the results of calling this method may vary depending on
the iteration order of map.
putAll in interface Map<K,V>m - IllegalArgumentException - if an attempt to put any
entry fails. Note that some map entries may have been added to the
bimap before the exception was thrown.public K removeByValue(Object value)
value - public boolean containsKey(Object key)
containsKey in interface Map<K,V>key - public boolean containsValue(Object value)
containsValue in interface Map<K,V>value - public ImmutableSet<K> keySet()
public ImmutableSet<V> values()
public BiMap<V,K> inversed()
public boolean isEmpty()
public int hashCode()
public boolean equals(Object obj)
Copyright © 2021. All rights reserved.