HashBiMultimap

Submitted by admin on Wed, 02/04/2015 - 11:00

Here, there is an example about HashBiMultimap along with the guava-12.0-SNAPSHOT.jar I have compiled from a version of guava.

To understand what is a HashBiMultimap data structure see
https://code.google.com/p/guava-libraries/wiki/NewCollectionTypesExplai…

<code>
import com.google.common.collect.HashBiMultimap;
public class Test {
public static void main(String[] args) {

HashBiMultimap<Object, Object> t = HashBiMultimap.create();

t.put("country", "peru");
t.put("country", "bolivia");
t.put("city", "lima");
t.put("city", "la paz");
t.put("city", "huanuco");
t.put("region", "peru");

System.out.println(t.inverse().get("peru"));

}
}
</code>

The output would be

<code>
[region, country]
</code>
Links

https://code.google.com/p/guava-libraries/source/browse/guava/src/com/g…

http://stackoverflow.com/questions/8066109/bidirectional-multi-valued-m…

Etiquetas