repositories
/
poolifier.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build: bump volta pnpm version
[poolifier.git]
/
src
/
deque.ts
diff --git
a/src/deque.ts
b/src/deque.ts
index fe82a79896a08757e3f261b66aa364b1407ab6e9..52441a3ec25f4f7251575104a0884f9ffeb22d00 100644
(file)
--- a/
src/deque.ts
+++ b/
src/deque.ts
@@
-1,19
+1,15
@@
-// Copyright Jerome Benoit. 2023. All Rights Reserved.
+// Copyright Jerome Benoit. 2023
-2024
. All Rights Reserved.
/**
/**
- *
Nod
e.
+ *
Linked list node interfac
e.
*
*
- * @typeParam T - Type of node data.
+ * @typeParam T - Type of
linked list
node data.
* @internal
*/
* @internal
*/
-export class Node<T> {
- public data: T
- public next?: Node<T>
- public prev?: Node<T>
-
- public constructor (data: T) {
- this.data = data
- }
+export interface ILinkedListNode<T> {
+ data: T
+ next?: ILinkedListNode<T>
+ prev?: ILinkedListNode<T>
}
/**
}
/**
@@
-24,8
+20,8
@@
export class Node<T> {
* @internal
*/
export class Deque<T> {
* @internal
*/
export class Deque<T> {
- private head?: Node<T>
- private tail?: Node<T>
+ private head?:
ILinkedList
Node<T>
+ private tail?:
ILinkedList
Node<T>
/** The size of the deque. */
public size!: number
/** The maximum size of the deque. */
/** The size of the deque. */
public size!: number
/** The maximum size of the deque. */
@@
-39,10
+35,10
@@
export class Deque<T> {
* Appends data to the deque.
*
* @param data - Data to append.
* Appends data to the deque.
*
* @param data - Data to append.
- * @returns The new size of the
que
ue.
+ * @returns The new size of the
deq
ue.
*/
public push (data: T): number {
*/
public push (data: T): number {
- const node
= new Node(data)
+ const node
: ILinkedListNode<T> = { data }
if (this.tail == null) {
this.head = this.tail = node
} else {
if (this.tail == null) {
this.head = this.tail = node
} else {
@@
-56,10
+52,10
@@
export class Deque<T> {
* Prepends data to the deque.
*
* @param data - Data to prepend.
* Prepends data to the deque.
*
* @param data - Data to prepend.
- * @returns The new size of the
que
ue.
+ * @returns The new size of the
deq
ue.
*/
public unshift (data: T): number {
*/
public unshift (data: T): number {
- const node
= new Node(data)
+ const node
: ILinkedListNode<T> = { data }
if (this.head == null) {
this.head = this.tail = node
} else {
if (this.head == null) {
this.head = this.tail = node
} else {