X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdeque.ts;h=52441a3ec25f4f7251575104a0884f9ffeb22d00;hb=27a8a097ad47621d1a914240d777921f129cff61;hp=257643726383945d81960ec2cd7be0c04d26eecb;hpb=b97b9dc23cec0006fb59ac15197d666307ab8cf5;p=poolifier.git diff --git a/src/deque.ts b/src/deque.ts index 25764372..52441a3e 100644 --- a/src/deque.ts +++ b/src/deque.ts @@ -35,13 +35,14 @@ export class Deque { * Appends data to the deque. * * @param data - Data to append. - * @returns The new size of the queue. + * @returns The new size of the deque. */ 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() @@ -51,13 +52,14 @@ export class Deque { * Prepends data to the deque. * * @param data - Data to prepend. - * @returns The new size of the queue. + * @returns The new size of the deque. */ 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()