From: Jérôme Benoit Date: Mon, 15 Jan 2024 20:41:24 +0000 (+0100) Subject: fix: fix push/unshift Deque X-Git-Tag: v3.1.19~5 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=938ced1a12539976a1b2d2118df1a1587b4ea5df;p=poolifier.git fix: fix push/unshift Deque Signed-off-by: Jérôme Benoit --- diff --git a/src/deque.ts b/src/deque.ts index 25764372..0d55f5b6 100644 --- a/src/deque.ts +++ b/src/deque.ts @@ -38,10 +38,11 @@ export class Deque { * @returns The new size of the queue. */ public push (data: T): number { - const node = { data, prev: this.tail } + const node: ILinkedListNode = { data } if (this.tail == null) { this.head = this.tail = node } else { + node.prev = this.tail this.tail = this.tail.next = node } return this.incrementSize() @@ -54,10 +55,11 @@ export class Deque { * @returns The new size of the queue. */ public unshift (data: T): number { - const node = { data, next: this.head } + const node: ILinkedListNode = { data } if (this.head == null) { this.head = this.tail = node } else { + node.next = this.head this.head = this.head.prev = node } return this.incrementSize()