Guava Collections - BiMap Interface

BiMap Interface

A BiMap is a special kind of map which maintains an inverse view of the map while ensuring that no duplicate values are present in the map and a value can be used safely to get the key back.

package org.fool.guava.collections;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

public class BiMapTest {
	public static void main(String[] args) {
		BiMap<Integer, String> empIDNameMap = HashBiMap.create();

		empIDNameMap.put(new Integer(101), "Mahesh");
		empIDNameMap.put(new Integer(102), "Sohan");
		empIDNameMap.put(new Integer(103), "Ramesh");
		
		System.out.println(empIDNameMap.inverse().get("Mahesh"));
	}
}

 output

101

猜你喜欢

转载自agilestyle.iteye.com/blog/2288061