HashBiMultimap

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/NewCollectionTypesExplained#BiMap

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"));
        
    }
}

The output would be

[region, country]

Links

Etiquetas
Attachment Size
guava-12.0-SNAPSHOT.jar1.72 MB 1.72 MB
guava-libraries-637b57166d09.tar_.gz1.9 MB 1.9 MB