-// Copyright Jerome Benoit. 2023. All Rights Reserved.
+// Copyright Jerome Benoit. 2023-2024. All Rights Reserved.
/**
* Linked list node interface.
* 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()
* 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()