ts-data-forge
    Preparing search index...

    Type Alias Queue<T>

    Queue: Readonly<
        {
            dequeue: () => Optional<T>;
            enqueue: (value: T) => void;
            isEmpty: boolean;
            size: SizeType.Arr;
        },
    >

    Interface for a high-performance queue with FIFO (First-In, First-Out) behavior.

    This interface defines a mutable queue data structure where elements are added to the back and removed from the front, maintaining the order in which they were added. The implementation uses a circular buffer for optimal performance, providing O(1) operations for both enqueue and dequeue operations.

    FIFO Behavior:

    • enqueue: Adds elements to the back of the queue
    • dequeue: Removes and returns elements from the front of the queue
    • Elements are processed in the exact order they were added

    Performance Characteristics:

    • Enqueue: O(1) amortized (O(n) when buffer needs resizing)
    • Dequeue: O(1) always
    • Size/isEmpty: O(1) always
    • Memory efficient with automatic garbage collection of removed elements

    Use Cases:

    • Task scheduling and job queues
    • Breadth-first search algorithms
    • Event processing systems
    • Producer-consumer patterns
    • Buffer management for streaming data

    Type Parameters

    • T

      The type of elements stored in the queue.