X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fdeque.ts;h=0d55f5b665115b3c5efc2580fcdb56562926b340;hb=e24f64b0df8534e9cff218338405bbd59695b469;hp=44431789f8808f96458fd200e24e6ac31c92ff5b;hpb=4335b463013675c6f5f0cd49c86ba7c75cb59c76;p=poolifier.git diff --git a/src/deque.ts b/src/deque.ts index 44431789..0d55f5b6 100644 --- 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. /** - * Linked list node. + * Linked list node interface. * * @typeParam T - Type of linked list node data. * @internal */ -export class LinkedListNode { - public data: T - public next?: LinkedListNode - public prev?: LinkedListNode - - public constructor (data: T) { - this.data = data - } +export interface ILinkedListNode { + data: T + next?: ILinkedListNode + prev?: ILinkedListNode } /** @@ -24,8 +20,8 @@ export class LinkedListNode { * @internal */ export class Deque { - private head?: LinkedListNode - private tail?: LinkedListNode + private head?: ILinkedListNode + private tail?: ILinkedListNode /** The size of the deque. */ public size!: number /** The maximum size of the deque. */ @@ -42,7 +38,7 @@ export class Deque { * @returns The new size of the queue. */ public push (data: T): number { - const node = new LinkedListNode(data) + const node: ILinkedListNode = { data } if (this.tail == null) { this.head = this.tail = node } else { @@ -59,7 +55,7 @@ export class Deque { * @returns The new size of the queue. */ public unshift (data: T): number { - const node = new LinkedListNode(data) + const node: ILinkedListNode = { data } if (this.head == null) { this.head = this.tail = node } else {