Class Deque<T>

Fixed capacity double-ended queue implemented as ring deque.

Type Parameters

  • T = any

Hierarchy

Constructors

  • Creates a new Deque instance of a fixed size.

    Type Parameters

    • T = any

    Parameters

    • Optional arrType: T[] = ...
    • Optional capacity: number = 1024

      The fixed size of the deque. Defaults to 1024.

    Returns Deque<T>

Properties

ArrayConstructor: any
capacity: number
count: number = 0
items: T[]
start: number = 0

Accessors

  • get size(): number
  • Returns the total number of elements in the deque.

    Returns number

Methods

  • Appends a new element to the end of the deque.

    Returns

    Returns the new size of the deque.

    Parameters

    • item: any

      Item to append.

    Returns number

  • Appends a new element to the beginning of the deque.

    Returns

    Returns the new size of the deque.

    Parameters

    • item: any

      Item to prepend.

    Returns number

  • Check if a given element is in the deque.

    Returns

    true if the value is found

    Parameters

    • x: any

      The value to find

    Returns boolean

  • Creates an iterator of [index, value] pairs for all elements in the deque.

    Returns

    Returns Iterable<[number, T]> & Iterator<[number, T], any, undefined>

  • Returns the first element that matches the iteratee function.

    Returns

    The element if exists

    Parameters

    • iteratee: Iteratee<T, any, any>

      A function that will be invoked per element

    Returns T

  • Returns the element at the beginning of the deque.

    Returns

    The element if exists

    Returns T

  • Calls iteratee function for every element in the deque.

    Parameters

    • iteratee: any

      A function that will be invoked per element

    Returns void

  • Returns the element at a specified index position in the deque.

    Returns

    The element if exists

    Parameters

    • index: any

      The given index

    Returns T

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

    Returns

    Returns the popped item.

    Returns T

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

    Returns

    Returns the removed deque element.

    Returns T

  • Returns a new array with all the elements in reverse order.

    Returns

    The elements reversed

    Returns any

  • Update the element at a given index.

    Parameters

    • index: number

      The given index

    • value: T

    Returns void

  • Returns a new array with all the elements in the order they were added to the deque.

    Returns

    The elements array

    Returns any

Generated using TypeDoc