Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions packages/client/lib/client/linked-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DoublyLinkedList<T> {
++this.#length;

if (this.#tail === undefined) {
return this.#tail = this.#head = {
return this.#head = this.#tail = {
previous: this.#head,
next: undefined,
value
Expand Down Expand Up @@ -73,7 +73,7 @@ export class DoublyLinkedList<T> {
--this.#length;
const node = this.#head;
if (node.next) {
node.next.previous = node.previous;
node.next.previous = undefined;
this.#head = node.next;
node.next = undefined;
} else {
Expand All @@ -87,15 +87,18 @@ export class DoublyLinkedList<T> {

if (this.#tail === node) {
this.#tail = node.previous;
}

}
if (this.#head === node) {
this.#head = node.next;
} else {
node.previous!.next = node.next;
node.previous = undefined;
if (node.previous) {
node.previous.next = node.next;
}
if (node.next) {
node.next.previous = node.previous;
}
}

node.previous = undefined;
node.next = undefined;
}

Expand All @@ -115,8 +118,9 @@ export class DoublyLinkedList<T> {
*nodes() {
let node = this.#head;
while(node) {
const next = node.next;
yield node;
node = node.next;
node = next;
}
}
}
Expand Down