MRUCache<K, V> class
Implements a Most Recently Used (MRU) Cache with fixed capacity.
The MRU cache stores key-value pairs up to a given capacity. When the cache is full and a new item is added, it evicts the least recently used item. Accessing or inserting a key moves it to the most recently used position.
Time Complexity: O(1) for get and put operations.
Example:
final cache = MRUCache<String, int>(2);
cache.put('a', 1);
cache.put('b', 2);
cache.get('a'); // Access 'a', now 'b' is least recently used
cache.put('c', 3); // Evicts 'b'
print(cache); // Outputs: {a: 1, c: 3}
Properties
Methods
-
get(
K key) → V? -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
put(
K key, V value) → void -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited