onCapacity method

  1. @override
void onCapacity(
  1. K key,
  2. V element
)

called if we want to insert another item denoted by key and element into the map. This method checks if the capacity is reached and eventually evicts old items.

Implementation

@override
void onCapacity(K key, V element) {
  if (length < capacity) return;
  storage.onCapacity(storage.keys.first);
}