LRUMap implements Map<K, V> { @Override public void putAll(Map<? extends K, ? extends V> m) { internalMap.putAll(m); } LRUMap();  LRUMap(final int maxSize); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override V get(Object key); @Override V put(K key, V value); @Override V remove(Object key); @Override void putAll(Map<? extends K, ? extends V> m); @Override void clear(); @Override Set<K> keySet(); @Override Collection<V> values(); @Override Set<Map.Entry<K, V>> entrySet(); static final int DEFAULT_MAX_SIZE; }
@Test public void testPutAll() { TreeMap<Integer, String> treeMap = new TreeMap<Integer, String>(); LRUMap<Integer, String> lruMap = new LRUMap<Integer, String>(3); treeMap.put(0, "0"); treeMap.put(1, "1"); treeMap.put(2, "2"); treeMap.put(3, "3"); lruMap.putAll(treeMap); assertEquals(3, lruMap.size()); assertFalse(lruMap.containsKey(0)); assertEquals("1", lruMap.get(1)); assertEquals("2", lruMap.get(2)); assertEquals("3", lruMap.get(3)); }