如何从HashMap<String,HashSet<String>> objects
中获取特定属性具有相同值的所有对象的列表.String保存属性,HashSet保存属性的值列表!
答案 0 :(得分:0)
Map<String,Set<String>> objects = new HashMap<String,Set<String>>();
// fill it up
String needle = "value";
List<String> results = new LinkedList<String>();
for(Map.Entry<String,Set<String>> entry : objects.entry set())
{
if(entry.getValue().contains(needle))
{
results.add(entry.getKey());
}
}
return results;