Created
June 5, 2019 17:35
-
-
Save jerolba/6bd3e1788c4d494705dce1be1b845597 to your computer and use it in GitHub Desktop.
This file contains 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
//BikeySet<Avenger, Film> avengerFilms = new TableBikeySet<>(); | |
BikeySet<String, String> avengerFilms = new TableBikeySet<>(); | |
avengerFilms.add("Hulk", "The Avengers"); | |
avengerFilms.add("Iron Man", "The Avengers"); | |
avengerFilms.add("Thor", "Avengers: Age of Ultron"); | |
avengerFilms.add("Thor", "Thor: Ragnarok"); | |
avengerFilms.add("Captain America", "Avengers: Infinity War"); | |
.... | |
if (avengerFilms.contains("Iron Man", "Black Panther")) { | |
.... | |
} | |
//Films in the Set | |
Set<String> filmsInSet = avengerFilms.columnKeySet(); | |
//Avengers in the Set | |
Set<String> avengersInSet = avengerFilms.rowKeySet(); | |
//Iron Man Movies | |
List<String> ironManFilms = avengerFilms.stream() | |
.filter(entry -> entry.getRow().equals("Iron Man")) | |
.map(Bikey::getColumn) | |
.collect(toList()); | |
//Call to a BiFunction for each entry | |
bikeySet.forEach(this::doSomething); | |
public void doSomething(String avenger, String film) { | |
.... | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment