build: bump volta pnpm version
[poolifier.git] / src / deque.ts
index 257643726383945d81960ec2cd7be0c04d26eecb..52441a3ec25f4f7251575104a0884f9ffeb22d00 100644 (file)
@@ -35,13 +35,14 @@ export class Deque<T> {
    * 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<T> = { 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<T> {
    * 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<T> = { data }
     if (this.head == null) {
       this.head = this.tail = node
     } else {
+      node.next = this.head
       this.head = this.head.prev = node
     }
     return this.incrementSize()