export default class SimpleQueue { get peek() { return this.store.get(this.head); } set peek(v) { this.store.set(this.head, v); } get isEmpty() { return this.head === this.tail; } private head = 0; private tail = 0; private readonly store: Map = new Map(); public enqueue(item: T) { this.store.set(this.tail,item); this.tail++; } public dequeue() { const { head, tail } = this; const size = tail - head; if (size <= 0) { return void 0; } const item = this.store.get(head); this.store.delete(head); this.head++; if (this.head === this.tail) { this.head = 0; this.tail = 0; } return item; } }