From 4335b463013675c6f5f0cd49c86ba7c75cb59c76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 15 Jan 2024 17:05:35 +0100 Subject: [PATCH] refactor: cleanup deque implementation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/deque.ts | 18 +++++++++--------- src/index.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) 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' -- 2.34.1