Class BiMap<K,V>
- java.lang.Object
-
- com.itextpdf.commons.datastructures.BiMap<K,V>
-
- Type Parameters:
K
- the type of the first keyV
- the type of the second key
public final class BiMap<K,V> extends java.lang.Object
A simple bi-directional map.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
removes all entries from the map.boolean
containsKey(K k)
Checks if the map contains the key.boolean
containsValue(V v)
Checks if the map contains the value.V
getByKey(K value)
Gets the value by key.K
getByValue(V key)
Gets the key by value.boolean
isEmpty()
Checks if the map is empty.void
put(K k, V v)
Puts the entry into the map.void
removeByKey(K k)
Removes the entry by key.void
removeByValue(V v)
Removes the entry by value.int
size()
Gets the size of the map.
-
-
-
Constructor Detail
-
BiMap
public BiMap()
Creates a newBiMap
instance.
-
-
Method Detail
-
put
public void put(K k, V v)
Puts the entry into the map. If the key already exists, the value will be overwritten. If the value already exists, the key will be overwritten. If both key and value already exist, the entry will be overwritten. If neither key nor value already exist, the entry will be added.- Parameters:
k
- the keyv
- the value
-
getByKey
public V getByKey(K value)
Gets the value by key.- Parameters:
value
- the key- Returns:
- the value
-
getByValue
public K getByValue(V key)
Gets the key by value.- Parameters:
key
- the value- Returns:
- the key
-
removeByKey
public void removeByKey(K k)
Removes the entry by key.- Parameters:
k
- the key
-
removeByValue
public void removeByValue(V v)
Removes the entry by value.- Parameters:
v
- the value
-
size
public int size()
Gets the size of the map.- Returns:
- the size of the map
-
clear
public void clear()
removes all entries from the map.
-
isEmpty
public boolean isEmpty()
Checks if the map is empty.- Returns:
- true, if the map is empty
-
containsKey
public boolean containsKey(K k)
Checks if the map contains the key.- Parameters:
k
- the key- Returns:
- true, if the map contains the key
-
containsValue
public boolean containsValue(V v)
Checks if the map contains the value.- Parameters:
v
- the value- Returns:
- true, if the map contains the value
-
-