Function useQueue

  • A custom hook for managing a queue of items.

    Type Parameters

    • Item

      Type of the queue elements.

    Parameters

    • initialValues: Queue<Item> = []

      Initial values for the queue.

    Returns {
        add: ((item) => void);
        clear: (() => void);
        isEmpty: boolean;
        peek: (() => undefined | Item);
        queue: Item[];
        remove: (() => undefined | Item);
        size: number;
    }

    • add: ((item) => void)
        • (item): void
        • Add an item to the end of the queue.

          Parameters

          • item: Item

            The item to enqueue.

          Returns void

    • clear: (() => void)
        • (): void
        • Empty the whole queue.

          Returns void

    • isEmpty: boolean

      A boolean to state if the queue is empty or not.

    • peek: (() => undefined | Item)
        • (): undefined | Item
        • Peek at the first item in the queue without removing it.

          Returns undefined | Item

          The first item in the queue, or undefined if the queue is empty.

    • queue: Item[]
    • remove: (() => undefined | Item)
        • (): undefined | Item
        • Remove an item from the head of the queue.

          Returns undefined | Item

          The item removed.

    • size: number

      The current size of the queue.

Generated using TypeDoc