operator [] method

  1. @override
V? operator [](
  1. K key
)
override

Retrieves the value associated with key.

Returns null if the key is not found. Accessing the key marks it as the most recently used item.

Implementation

@override
V? operator [](K key) {
  final value = _cache.remove(key);
  if (value != null) {
    // Re-insert to move to the end (most recently used position)
    _cache[key] = value;
  }
  return value;
}