Class representing a Double Ended Queue (Deque). Allows insertion and removal of elements from both ends of the queue.

Type Parameters

  • T

    The type of elements that the deque will store.

Constructors

  • Creates an instance of the Deque class with a specified capacity. Initializes the deque with an empty list and sets head and tail pointers.

    Type Parameters

    • T

    Parameters

    • capacity: number

      The initial capacity of the deque.

    Returns Dequeue<T>

Properties

capacity: number
head: number
list: T[]
tail: number

Methods

  • Appends an element at the end of the deque.

    Parameters

    • value: T

    Returns boolean

    Returns true if successfully, otherwise (the deque is full) it will returns false.

  • Remove all elements of the current deque.

    Returns void

  • Returns the current number of elements in the deque.

    Returns number

    The number of elements currently stored in the deque.

  • Checks if the deque is full.

    Returns boolean

    True if the deque has reached its capacity, otherwise false.

  • Returns the element at the front of the deque without removing it.

    Returns undefined | T

    The element at the front of the deque, or undefined if the deque is empty.

  • Returns the element at the end of the deque without removing it.

    Returns undefined | T

    The element at the front of the deque, or undefined if the deque is empty.

  • Removes and returns the element at the end of the deque.

    Returns undefined | T

    The element at the end of the deque, or undefined if the deque is empty.

  • Removes and returns the element at the front of the deque.

    Returns undefined | T

    The element at the front of the deque, or undefined if the deque is empty.

Generated using TypeDoc