intermediate
This commit is contained in:
@@ -34,7 +34,7 @@ class LRUCache<K, V> {
|
||||
return value;
|
||||
}
|
||||
|
||||
void set(K key, V value) {
|
||||
V set(K key, V value) {
|
||||
if (_cache.containsKey(key)) {
|
||||
_cache.remove(key); // Remove the existing item before updating.
|
||||
} else if (_cache.length == _capacity) {
|
||||
@@ -43,6 +43,6 @@ class LRUCache<K, V> {
|
||||
); // Explicitly remove the least recently used item if at capacity.
|
||||
}
|
||||
|
||||
_cache[key] = value; // Inserting or updating the item.
|
||||
return _cache[key] = value; // Inserting or updating the item.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user