LRU.d.ts 651 B

12345678910111213141516171819202122232425262728
  1. export declare class Entry<T> {
  2. value: T;
  3. key: string | number;
  4. next: Entry<T>;
  5. prev: Entry<T>;
  6. constructor(val: T);
  7. }
  8. export declare class LinkedList<T> {
  9. head: Entry<T>;
  10. tail: Entry<T>;
  11. private _len;
  12. insert(val: T): Entry<T>;
  13. insertEntry(entry: Entry<T>): void;
  14. remove(entry: Entry<T>): void;
  15. len(): number;
  16. clear(): void;
  17. }
  18. export default class LRU<T> {
  19. private _list;
  20. private _maxSize;
  21. private _lastRemovedEntry;
  22. private _map;
  23. constructor(maxSize: number);
  24. put(key: string | number, value: T): T;
  25. get(key: string | number): T;
  26. clear(): void;
  27. len(): number;
  28. }