Options
All
  • Public
  • Public/Protected
  • All
Menu

List is a sequence container that supports constant-time insertion and removal from the front and back of the container. It does not support random access, meaning there is no indexing operator. It is implemented as a doubly-linked list.

Type parameters

  • T

Hierarchy

  • List

Implements

  • Iterable<T>

Index

Constructors

Accessors

Methods

Constructors

constructor

Accessors

length

length:

Methods

__@iterator

  • __@iterator(): IterableIterator<T>
  • Returns IterableIterator<T>

    An iterable iterator over the elements in this List.

pop

  • pop(): T | undefined
  • Removes the element at the back of the List, if it exists. Time complexity: O(1)

    Returns T | undefined

    undefined if the List is empty, else the removed element.

push

  • push(...elements: Array<T>): number
  • Time complexity: O(n), where n is the number of arguments.

    Parameters

    • Rest ...elements: Array<T>

      The elements to append onto the back of this List.

    Returns number

    The number of elements contained in this List.

shift

  • shift(): T | undefined
  • Removes the element at the front of the List, if it exists. Time complexity: O(1)

    Returns T | undefined

    undefined if the List is empty, else the removed element.

unshift

  • unshift(...elements: Array<T>): number
  • Appends elements as if concatenating onto the front. Time complexity: O(n), where n is the number of arguments.

    Parameters

    • Rest ...elements: Array<T>

      The elements to append onto the front of this List.

    Returns number

    The number of elements contained in this List.

Static from

  • from<T>(init: Iterable<T>): List<T>
  • Time complexity: O(n), where n is the number of elements iterated over.

    Type parameters

    • T

    Parameters

    • init: Iterable<T>

      The sequence to populate a List with.

    Returns List<T>

    A List with all elements shallowly copied from init.

Static of

  • of<T>(...elements: Array<T>): List<T>
  • Implemented using #from. Time complexity: O(n), where n is the number of arguments.

    see

    from

    Type parameters

    • T

    Parameters

    • Rest ...elements: Array<T>

      The elements to copy into a new List.

    Returns List<T>

    A List of elements shallowly copied from the arguments.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc