The type of elements stored in the queue.
Optional
initialValues: readonly T[]Optional array of initial elements to populate the queue. Elements will be dequeued in the same order they appear in the array. If provided, the initial buffer capacity will be at least twice the array length.
A new Queue instance optimized for high-performance FIFO operations.
const queue = createQueue<number>();
assert.ok(queue.isEmpty);
assert(queue.size === 0);
queue.enqueue(1);
queue.enqueue(2);
assert.notOk(queue.isEmpty);
assert(queue.size === 2);
assert.deepStrictEqual(queue.dequeue(), Optional.some(1));
assert.deepStrictEqual(queue.dequeue(), Optional.some(2));
assert.deepStrictEqual(queue.dequeue(), Optional.none);
const seededQueue = createQueue(['first', 'second']);
assert(seededQueue.size === 2);
assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('first'));
assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('second'));
Creates a new Queue instance with FIFO (First-In, First-Out) behavior using a high-performance circular buffer.
This factory function creates an optimized queue implementation that maintains excellent performance characteristics for both enqueue and dequeue operations. The underlying circular buffer automatically resizes to accommodate growing workloads while providing predictable O(1) operations.
Implementation Features:
Performance Benefits: