java - searching for keys when values are selected -


i using google table store collection in format shown:

import com.google.common.collect.hashbasedtable; import com.google.common.collect.lists; import com.google.common.collect.table;  public class mapdemo {      public static void main(string[] args) {          final table<string, string, list<string>> values = hashbasedtable                 .create();         values.put("b1", "rtyname",                 lists.newarraylist("weepn", "weepfnb", "eedgeft", "xbteehy"));         values.put("b2", "euopname",                 lists.newarraylist("aaa", "bbbb", "ccc", "dddd"));         system.out.println(values.get("b1", "rtyname")); // prints list         system.out.println(values.get("b2", "xxxname")); // prints list     } } 

now, outputs:

[weepn, weepfnb, eedgeft, xbteehy] [aaa, bbbb, ccc, dddd] 

i want customize same program, such lets if 1 of value of list, select lets below pair

"b1", "rtyname", lists.newarraylist("weepn", "weepfnb", "eedgeft", "xbteehy" 

i select value weepn should print rtyname , b1 similiarly let select value aaa should print xxxname , b2.

so, please advise how achieve want search values.

there no direct way keys on based of value can iterate on cellset(row) of table , check each list if contains value or not . if doing big map can think of using bimap
//code iterate

for(final cell<string, string, list<string>> row : values.cellset()){            if(row.getvalue().contains(val)){                system.out.println(//desired output);            } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -