Home Reference Source

src/queue/lru-cache.ts

// The task is to design and implement methods of an LRU cache.
// The class has two methods get() and set() which are defined as follows.
// get(x)   : Returns the value of the key x if the key exists in the cache otherwise returns -1.
// set(x,y) : inserts the value if the key x is not already present.
// If the cache reaches its capacity it should invalidate the least recently used item before inserting the new item.
// In the constructor of the class the size of the cache should be intitialized.
import { Queue } from "./queue";

export class LRUCache<T> {
    // This problem requires implementation of linkedhashmap.
    constructor(size: number) {
        // his.queue = new Queue(size);
    }

    public get(x: number) {
        // empty
    }

    public set(x: T, y: T) {
        // empty
    }
}