From 18be03bfa6f9edc6caa989da3b2d846ff11a8129 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Tue, 1 Jul 2025 22:01:07 -0400 Subject: [PATCH] Add stub implementation for my best friend, the humble circular queue Add stubs for a custom circular queue implementation for the historical data in the parking repo --- src/types/CircularQueue.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/types/CircularQueue.ts diff --git a/src/types/CircularQueue.ts b/src/types/CircularQueue.ts new file mode 100644 index 0000000..57298a0 --- /dev/null +++ b/src/types/CircularQueue.ts @@ -0,0 +1,27 @@ +export class CircularQueue { + private startIndex: number; + private endIndex: number; + private _data: T[]; + + constructor( + size: number, + ) { + // See the Mozilla documentation on sparse arrays (*not* undefined values) + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays + this._data = new Array(size); + this.startIndex = 0; + this.endIndex = size - 1; + } + + appendWithSorting = ( + data: T, + sortingCallback: ((a: T, b: T) => number) | undefined + ) => { + // In case something is added that's not sorted, the sortingCallback + // will be used to sort + } + + popFront = (data: T) => { + + } +}