460
461
protected trimNew(newSize: number) {
462
>
if (newSize >= this.size) {
map.ts
463
return;
464
}
465
>
if (newSize === 0) {
map.ts
466
this.clear();
467
return;
468
}
469
>
let current = this._tail;
map.ts
470
>
let currentSize = this.size;
471
>
while (current && currentSize > newSize) {
472
>
this._map.delete(current.key);
473
>
current = current.previous;
474
>
currentSize--;
475
>
}
476
>
this._tail = current;
477
>
this._size = currentSize;
478
>
if (current) {
479
>
current.next = undefined;
480
>
}
481
>
this._state++;
482
>
}
483
484
private addItemFirst(item: Item<K, V>): void {