Created
December 21, 2017 08:48
-
-
Save clarkdo/233cd35a3e62820455b8dd6595d7fb76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.google.common.collect.Lists; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class SearchInList { | |
| public static final ArrayList<List<String>> LIST = Lists.newArrayList( | |
| Lists.newArrayList("a", "b"), | |
| Lists.newArrayList("c", "d"), | |
| Lists.newArrayList("e", "f", "g"), | |
| Lists.newArrayList("h", "i", "j", "k"), | |
| Lists.newArrayList("l", "m", "n", "o") | |
| ); | |
| public static final boolean containsIn2D (List<List<String>> list, String str) { | |
| return list.stream().flatMap(l -> l.parallelStream()).anyMatch(v -> v.equals(str)); | |
| } | |
| public static void main(String[] args) { | |
| System.out.println(containsIn2D(LIST, "a")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment