1=[Fletcher Christian, No, Visualisation of Egocentric Networks, Exploring the Irish Political Landscape on Twitter, Twitter Network Analysis, A Web-Based Server Energy Model Generator, Recommending Movies Using Curated IMDb Lists, Travel Planner for Commuters, Analysis of urban street networks - constructing a dual representation, Biography Reading Media Assistant]
我有hash-table
喜欢上面。我想知道 Fletcher Christian 是否包含在Hash-Table
值
这里的值是一个向量
答案 0 :(得分:2)
只需查看所有值并检查:
static boolean contains (Hashtable <Integer, Vector <String>> map, String value){
for (Vector<String> values : map.values()){
if (values.contains(value))
return true;
}
return false;
}
在Java 8中,您可以使用单行执行此操作:
static boolean contains (Hashtable <Integer, Vector<String>> map, String value){
return map.values().stream().anyMatch(list -> list.contains(value));
}