Skip to content

Instantly share code, notes, and snippets.

@adamv
Last active August 15, 2020 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamv/652e13578a46ef236e6e1ed3a77d7ce2 to your computer and use it in GitHub Desktop.
Save adamv/652e13578a46ef236e6e1ed3a77d7ce2 to your computer and use it in GitHub Desktop.
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