@Test public void testImmediatePurge() { for(int i = 0; i < MAX_CAPACITY; i++) { map.put("key" + i, "value" + i); } Assert.assertEquals(MAX_CAPACITY, map.size); for(int i = MAX_CAPACITY; i < MAX_CAPACITY * 2; i++) { map.put("key" + i, "value" + i); Assert.assertEquals(MAX_CAPACITY, map.size); } }
@Override public V put(K key, V value) { while(super.size >= maxCapacity) { purge(); } final V result = super.put(key, value); accessCounter.getAndIncrement(key, -1, 1); return result; }
LruObjectMap extends ObjectMap<K, V> { @Override public V put(K key, V value) { while(super.size >= maxCapacity) { purge(); } final V result = super.put(key, value); accessCounter.getAndIncrement(key, -1, 1); return result; } }
LruObjectMap extends ObjectMap<K, V> { @Override public V put(K key, V value) { while(super.size >= maxCapacity) { purge(); } final V result = super.put(key, value); accessCounter.getAndIncrement(key, -1, 1); return result; } LruObjectMap();  LruObjectMap(int initialCapacity);  LruObjectMap(int initialCapacity, float loadFactor);  LruObjectMap(ObjectMap<? extends K, ? extends V> map);  LruObjectMap(int initialCapacity, int maxCapacity);  LruObjectMap(int initialCapacity, int maxCapacity, float loadFactor);  LruObjectMap(ObjectMap<? extends K, ? extends V> map, int maxCapacity); }
LruObjectMap extends ObjectMap<K, V> { @Override public V put(K key, V value) { while(super.size >= maxCapacity) { purge(); } final V result = super.put(key, value); accessCounter.getAndIncrement(key, -1, 1); return result; } LruObjectMap();  LruObjectMap(int initialCapacity);  LruObjectMap(int initialCapacity, float loadFactor);  LruObjectMap(ObjectMap<? extends K, ? extends V> map);  LruObjectMap(int initialCapacity, int maxCapacity);  LruObjectMap(int initialCapacity, int maxCapacity, float loadFactor);  LruObjectMap(ObjectMap<? extends K, ? extends V> map, int maxCapacity); @Override V put(K key, V value); @Override void putAll(ObjectMap<? extends K, ? extends V> map); @Override V get(K key); @Override V get(K key, V defaultValue); @Override V remove(K key); @Override void clear(); int getMaxCapacity(); }
LruObjectMap extends ObjectMap<K, V> { @Override public V put(K key, V value) { while(super.size >= maxCapacity) { purge(); } final V result = super.put(key, value); accessCounter.getAndIncrement(key, -1, 1); return result; } LruObjectMap();  LruObjectMap(int initialCapacity);  LruObjectMap(int initialCapacity, float loadFactor);  LruObjectMap(ObjectMap<? extends K, ? extends V> map);  LruObjectMap(int initialCapacity, int maxCapacity);  LruObjectMap(int initialCapacity, int maxCapacity, float loadFactor);  LruObjectMap(ObjectMap<? extends K, ? extends V> map, int maxCapacity); @Override V put(K key, V value); @Override void putAll(ObjectMap<? extends K, ? extends V> map); @Override V get(K key); @Override V get(K key, V defaultValue); @Override V remove(K key); @Override void clear(); int getMaxCapacity(); static final int DEFAULT_MAX_CAPACITY; }