mirror of
https://github.com/brendan-ch/project-inter-server.git
synced 2026-04-17 07:50:31 +00:00
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
This commit is contained in:
27
src/types/CircularQueue.ts
Normal file
27
src/types/CircularQueue.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export class CircularQueue<T> {
|
||||
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<T>(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) => {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user