gradum-kit - v0.1.0
    Preparing search index...

    Class GradumQueue<Type>

    GradumQueue

    A first-in, first-out queue. push adds to the back, pop takes from the front, and addOnTop jumps the line. Popping does not shift the backing array, so draining a long queue stays cheap.

    Type Parameters

    • Type = any

      The type of the queued values.

    Index
    • get size(): number

      Returns number

      The number of values still waiting to be popped.

    • get isEmpty(): boolean

      Returns boolean

      Whether the queue has nothing left to pop.

    • Parameters

      • ...values: Type[]

        The values to enqueue, in order.

      Returns this

      Itself, allowing for method chaining.

      Add one or more values to the back of the queue.

    • Parameters

      • ...values: Type[]

        The values to enqueue, in order.

      Returns this

      Itself, allowing for method chaining.

      Add one or more values to the front of the queue, so they are popped before everything already queued.

    • Returns Type

      The removed value, or undefined if the queue is empty.

      Take the value at the front of the queue and remove it.

    • Returns Type

      The next value to be popped, or undefined if the queue is empty.

      Read the value at the front of the queue without removing it.

    • Parameters

      • value: Type

        The value to look for, compared by identity.

      Returns boolean

      Whether the value is present.

      Check whether a value is queued.

    • Parameters

      • Optionalentry: Type

        Restrict deduplication to this value, leaving every other duplicate in place. Omit it to deduplicate the whole queue.

      Returns this

      Itself, allowing for method chaining.

      Drop repeated values, keeping the earliest occurrence of each so queue order is preserved. Mutates the queue.

    • Returns this

      Itself, allowing for method chaining.

      Discard every queued value.

    • Returns Type[]

      A new array of the values still waiting to be popped, front first. Already popped values are excluded.

      Snapshot the pending values.

    • Returns GradumQueue<Type>

      A new queue holding the same pending values in the same order. The values themselves are shared, not copied.

      Copy the queue.

    • Parameters

      • value: Type

        The value to remove, compared by identity.

      Returns boolean

      Whether a matching value was found and removed.

      Remove the first pending occurrence of a value, wherever it sits in the queue.