From: Jérôme Benoit Date: Mon, 15 Jan 2024 16:05:35 +0000 (+0100) Subject: refactor: cleanup deque implementation X-Git-Tag: v3.1.19~9 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4335b463013675c6f5f0cd49c86ba7c75cb59c76;p=poolifier.git refactor: cleanup deque implementation Signed-off-by: Jérôme Benoit --- diff --git a/src/deque.ts b/src/deque.ts index fe82a798..44431789 100644 --- a/src/deque.ts +++ b/src/deque.ts @@ -1,15 +1,15 @@ // Copyright Jerome Benoit. 2023. All Rights Reserved. /** - * Node. + * Linked list node. * - * @typeParam T - Type of node data. + * @typeParam T - Type of linked list node data. * @internal */ -export class Node { +export class LinkedListNode { public data: T - public next?: Node - public prev?: Node + public next?: LinkedListNode + public prev?: LinkedListNode public constructor (data: T) { this.data = data @@ -24,8 +24,8 @@ export class Node { * @internal */ export class Deque { - private head?: Node - private tail?: Node + private head?: LinkedListNode + private tail?: LinkedListNode /** The size of the deque. */ public size!: number /** The maximum size of the deque. */ @@ -42,7 +42,7 @@ export class Deque { * @returns The new size of the queue. */ public push (data: T): number { - const node = new Node(data) + const node = new LinkedListNode(data) if (this.tail == null) { this.head = this.tail = node } else { @@ -59,7 +59,7 @@ export class Deque { * @returns The new size of the queue. */ public unshift (data: T): number { - const node = new Node(data) + const node = new LinkedListNode(data) if (this.head == null) { this.head = this.tail = node } else { diff --git a/src/index.ts b/src/index.ts index 7c438e3e..1548487f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -74,5 +74,5 @@ export type { Writable } from './utility-types.js' export type { CircularArray } from './circular-array.js' -export type { Deque, Node } from './deque.js' +export type { Deque, LinkedListNode } from './deque.js' export { availableParallelism } from './utils.js'