/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize size limit */ public LRUMap(Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with the given max size. * * @param pMaxSize size limit */ public LRUMap(int pMaxSize) { super(null, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pBacking the backing map of this map. Must be either empty, or * the same map as {@code pContents}. * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize max size */ public LRUMap(Map<K, Entry<K, V>> pBacking, Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pBacking, pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with the given max size. * * @param pMaxSize size limit */ public LRUMap(int pMaxSize) { super(null, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize size limit */ public LRUMap(Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize size limit */ public LRUMap(Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with the given max size. * * @param pMaxSize size limit */ public LRUMap(int pMaxSize) { super(null, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with the given max size. * * @param pMaxSize size limit */ public LRUMap(int pMaxSize) { super(null, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize size limit */ public LRUMap(Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pBacking the backing map of this map. Must be either empty, or * the same map as {@code pContents}. * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize max size */ public LRUMap(Map<K, Entry<K, V>> pBacking, Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pBacking, pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pBacking the backing map of this map. Must be either empty, or * the same map as {@code pContents}. * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize max size */ public LRUMap(Map<K, Entry<K, V>> pBacking, Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pBacking, pContents, true); setMaxSize(pMaxSize); }
/** * Creates an LRUMap with initial mappings from the given map, * and the given max size. * * @param pBacking the backing map of this map. Must be either empty, or * the same map as {@code pContents}. * @param pContents the map whose mappings are to be placed in this map. * May be {@code null}. * @param pMaxSize max size */ public LRUMap(Map<K, Entry<K, V>> pBacking, Map<? extends K, ? extends V> pContents, int pMaxSize) { super(pBacking, pContents, true); setMaxSize(pMaxSize); }
/** * Test that the size of the map is reduced immediately * when setMaximumSize(int) is called */ @Test public void testSetMaximumSize() { LRUMap<String, String> map = new LRUMap<String, String>(6); map.put("1","1"); map.put("2","2"); map.put("3","3"); map.put("4","4"); map.put("5","5"); map.put("6","6"); map.setMaxSize(3); assertTrue("map should have size = 3, but actually = " + map.size(), map.size() == 3); }
/** * Method testWrapMaxSize */ @Test public void testWrapMaxSize() { LRUMap lru = new LRUMap(); lru.setMaxSize(2); TimeoutMap map = new TimeoutMap(lru, null, 1000L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); assertNull(map.put("third", "value-3")); assertEquals("value-3", map.get("third")); // This value should have expired assertNull(map.get("key")); // These should be left assertEquals("value-2", map.get("another")); assertEquals("value-3", map.get("third")); }
/** * Test that the size of the map is reduced immediately * when setMaximumSize(int) is called */ public void testSetMaximumSize() { LRUMap map = new LRUMap(6); map.put("1","1"); map.put("2","2"); map.put("3","3"); map.put("4","4"); map.put("5","5"); map.put("6","6"); map.setMaxSize(3); assertTrue("map should have size = 3, but actually = " + map.size(), map.size() == 3); }
/** * Test that the size of the map is reduced immediately * when setMaximumSize(int) is called */ public void testSetMaximumSize() { LRUMap<String, String> map = new LRUMap<String, String>(6); map.put("1","1"); map.put("2","2"); map.put("3","3"); map.put("4","4"); map.put("5","5"); map.put("6","6"); map.setMaxSize(3); assertTrue("map should have size = 3, but actually = " + map.size(), map.size() == 3); }
/** * Test that the size of the map is reduced immediately * when setMaximumSize(int) is called */ @Test public void testSetMaximumSize() { LRUMap<String, String> map = new LRUMap<String, String>(6); map.put("1","1"); map.put("2","2"); map.put("3","3"); map.put("4","4"); map.put("5","5"); map.put("6","6"); map.setMaxSize(3); assertTrue("map should have size = 3, but actually = " + map.size(), map.size() == 3); }
/** * Method testWrapMaxSize */ public void testWrapMaxSize() { LRUMap lru = new LRUMap(); lru.setMaxSize(2); TimeoutMap map = new TimeoutMap(lru, null, 1000L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); assertNull(map.put("third", "value-3")); assertEquals("value-3", map.get("third")); // This value should have expired assertNull(map.get("key")); // These should be left assertEquals("value-2", map.get("another")); assertEquals("value-3", map.get("third")); }
/** * Method testWrapMaxSize */ public void testWrapMaxSize() { LRUMap lru = new LRUMap(); lru.setMaxSize(2); TimeoutMap map = new TimeoutMap(lru, null, 1000L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); assertNull(map.put("third", "value-3")); assertEquals("value-3", map.get("third")); // This value should have expired assertNull(map.get("key")); // These should be left assertEquals("value-2", map.get("another")); assertEquals("value-3", map.get("third")); }
/** * Method testWrapMaxSize */ @Test public void testWrapMaxSize() { LRUMap lru = new LRUMap(); lru.setMaxSize(2); TimeoutMap map = new TimeoutMap(lru, null, 1000L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); assertNull(map.put("third", "value-3")); assertEquals("value-3", map.get("third")); // This value should have expired assertNull(map.get("key")); // These should be left assertEquals("value-2", map.get("another")); assertEquals("value-3", map.get("third")); }