Code Explainers

Code explainers tagged #insertion-order

javascript
class LRUCache {
  constructor(capacity) {
    if (capacity < 1) throw new RangeError('capacity must be positive');
    this.capacity = capacity;

Building an LRU cache with a JS Map

lru-cache data-structures insertion-order
Intermediate 8 steps
typescript
class LRUCache<K, V> {
  private readonly capacity: number;
  private readonly map: Map<K, V>;
 

Building an LRU cache on a JS Map

caching data-structures generics
Intermediate 8 steps