Last active
August 15, 2020 03:05
-
-
Save adamv/652e13578a46ef236e6e1ed3a77d7ce2 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
import java.util.AbstractMap; | |
import java.util.ArrayList; | |
import java.util.Map; | |
import java.util.function.BiConsumer; | |
public class EntryList<K,V> extends ArrayList<Map.Entry<K,V>> { | |
public boolean add(K key, V value) { | |
return this.add(new AbstractMap.SimpleEntry<>(key, value)); | |
} | |
public void forEach(BiConsumer<K,V> action) { | |
this.forEach(entry -> action.accept(entry.getKey(), entry.getValue())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment