检查字符串包含在哈希表值中
check String contains inside HashTable Value
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
喜欢 above.i 想要查找 Fletcher Christian 是否包含在 Hash-Table
值
中
这里的值是一个向量
只需遍历所有值并检查:
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));
}
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
喜欢 above.i 想要查找 Fletcher Christian 是否包含在 Hash-Table
值
这里的值是一个向量
只需遍历所有值并检查:
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));
}