LRUCache(int capacity)
initializes the cache to store data of size: capacity.int get(int key)
returns the value of the key if it exists, otherwise returns -1.void add(int key, int value)
updates the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
skaul05 / lru Goto Github PK
View Code? Open in Web Editor NEWLeast Recently Used Cache
License: Apache License 2.0