首页 > 代码库 > Guava bimap

Guava bimap

A bimap (or "bidirectional map") is a map that preserves the uniqueness of
its values as well as that of its keys. This constraint enables bimaps to
support an "inverse view", which is another bimap containing the same entries
as this bimap but with reversed keys and values.

从注释来看,一个biMap是一个值有唯一性的Map。可以通过inverse()方法进行key与value的反转。

如果put操作时,插入不同key的相同value值,那么会抛出“Exception in thread "main" java.lang.IllegalArgumentException: value already present:”异常

Guava bimap