LRUCache<K, V> class

A simple LRU (Least Recently Used) cache implementation.

When the cache reaches its maximum size, the least recently accessed item is removed to make room for new entries.

Constructors

LRUCache(int maxSize)
Creates an LRU cache with the specified maximum size.

Properties

hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Returns whether the cache is empty
no setter
maxSize → int
Maximum number of entries the cache can hold
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size → int
Returns the number of items in the cache
no setter

Methods

clear() → void
Clears all entries from the cache
containsKey(K key) → bool
Checks if a key is in the cache
get(K key) → V?
Gets a value from the cache, or null if not present.
getOrPut(K key, V compute()) → V
Gets a value or computes it if not present.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
put(K key, V value) → void
Puts a value in the cache.
remove(K key) → V?
Removes a key from the cache
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited