A bimap i.e, bidirectional map is a map that preserves the uniqueness of its values as well as that of its keys. BiMaps support inverse view, which is another bimap containing the same entries as this bimap but with reversed keys and values.
Declaration : The declaration for com.google.common.collect.Bimap<K, V> interface is as :
@GwtCompatible public interface BiMap<K, V> extends Map<K, V>
Below given are some methods provided by Guava BiMap Interface :
Return Values & Exceptions :
- put : Throws IllegalArgumentException if the given value is already bound to a different key in this bimap. The bimap will remain unmodified in this event.
- forcePut : Returns the value which was previously associated with the key, which may be null, or null if there was no previous entry.
- putAll : Throws 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.
- values : Returns a Set, instead of the Collection specified in the Map interface, as a bimap has unique values.
- inverse : Returns the inverse view of this bimap.
Below given is the implementation for Guava BiMap interface :
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Range Class | Guava | Java
- Ordering Class | Guava | Java
- Preconditions | Guava | Java
- BigIntegerMath Class | Guava | Java
- Java Guava | mean() method of IntMath Class
- Multiset Interface | Guava | Java
- Guava Library in Java
- Optional Class | Guava | Java
- MultiMap in Java Guava
- Table | Guava | Java
- IntMath Class | Guava | Java
- LongMath Class | Guava | Java
- Ints Class | Guava | Java
- Chars Class | Guava | Java
- Longs Class | Guava | Java
- Bytes Class | Guava | Java
- Shorts Class | Guava | Java
- Doubles Class | Guava | Java
- Booleans Class | Guava | Java
- Floats Class | Guava | Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.