import java.util.HashMap; import java.util.Map; public class Pair { private K first; private V second; public Pair(K first, V second) { this.first = first; this.second = second; } public K getFirst() { return first; } public V getSecond() { return second; } public Pair swap() { return new Pair<>(second, first); } @Override public String toString() { return "Pair{" + first + ", " + second + "}"; } } class Cache { private final Map cache; public Cache() { this.cache = new HashMap<>(); } public void put(K key, V value) { cache.put(key, value); } public V get(K key) { return cache.get(key); } public V remove(K key) { return cache.remove(key); } public void clear() { cache.clear(); } public boolean containsKey(K key) { return cache.containsKey(key); } public int size() { return cache.size(); } public boolean isEmpty() { return cache.isEmpty(); } }