简体   繁体   中英

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]

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

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));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM