Reputation: 2597
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]
I Have hash-table
like above.i want to find whether Fletcher Christian is contained inside the Hash-Table
value
here value is a vector
Upvotes: 0
Views: 605
Reputation: 7986
Simply go over all values and check :
static boolean contains (Hashtable <Integer, Vector <String>> map, String value){
for (Vector<String> values : map.values()){
if (values.contains(value))
return true;
}
return false;
}
In Java 8 you can do it with a single row:
static boolean contains (Hashtable <Integer, Vector<String>> map, String value){
return map.values().stream().anyMatch(list -> list.contains(value));
}
Upvotes: 2