put method
void
put(
- K key,
- V value
Associates the key with the given value.
If the key was already in the cache, its associated value is changed. If the cache is full, the least recently used item is evicted.
Implementation
void put(K key, V value) {
if (_cache.containsKey(key)) {
_cache.remove(key);
} else if (_cache.length >= maxSize) {
_cache.remove(_cache.keys.first);
}
_cache[key] = value;
}