X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fdeque.ts;h=0d55f5b665115b3c5efc2580fcdb56562926b340;hb=8876cdb81fda8f3245a463d6202c88bb99569a23;hp=027aa70dd94def236319bffaa565235d00244045;hpb=b1577cd97272354f930ee506a09a4d930903c68c;p=poolifier.git diff --git a/src/deque.ts b/src/deque.ts index 027aa70d..0d55f5b6 100644 --- a/src/deque.ts +++ b/src/deque.ts @@ -1,4 +1,4 @@ -// Copyright Jerome Benoit. 2023. All Rights Reserved. +// Copyright Jerome Benoit. 2023-2024. All Rights Reserved. /** * Linked list node interface. @@ -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()