@ceeblue/web-utils
    Preparing search index...

    Class Queue<Type>

    Queue typed similar to a std::queue with possibility to limit the capacity like a FIFO

    const queue = new Queue<number>(2);
    queue.push(1); // [1]
    queue.push(2); // [1,2]
    queue.push(3); // [2,3] 1 has been removed to respect 2 capacity

    Type Parameters

    • Type

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Instanciate a new queue object with the type passed as template

      Type Parameters

      • Type

      Parameters

      • Optionalcapacity: number

        if set it limits the size of the queue, any exceding element pops the first element pushed (FIFO)

      Returns Queue<Type>

    Accessors

    • get capacity(): number | undefined

      Maximum capacity for the queue, if not set queue has unlimited capacity

      Returns number | undefined

    • set capacity(value: number | undefined): void

      Set a maximum capacity for the queue, if you push new value exceding this capacity the firsts are removed (FIFO) if set to undefined the queue is unlimited

      Parameters

      • value: number | undefined

      Returns void

    • get size(): number

      Number of element in the queue

      Returns number

    Methods

    • Iterator though queue's elements

      Returns IterableIterator<Type>

    • Pop the first element from the queue

      Returns Type | undefined

      The first element removed