do not add/remove null values

This commit is contained in:
2020-10-04 17:17:32 +02:00
parent ea7ba042df
commit fbd07e465b

View File

@@ -20,8 +20,12 @@ public class LRUCache<K, V> {
} }
public V put(final K key, final V value) { public V put(final K key, final V value) {
if (value == null) {
return remove(key);
} else {
return cache.put(key, value); return cache.put(key, value);
} }
}
public V get(final K key) { public V get(final K key) {
final V result = cache.get(key); final V result = cache.get(key);