Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface List<T>

Represents a linked list, that can be a SinglyLinkedList or a DoublyLinkedList.

Type parameters

  • T

Hierarchy

  • List

Implemented by

Index

Methods

filter

  • Filters out elements and returns a new List The original Lise remains unaltered.

    Parameters

    Returns List<T>

    The new List

get

  • get(value: T): ListNode<T> | undefined
  • Returns the first encountered element with matching value.

    Parameters

    • value: T

      The tested value.

    Returns ListNode<T> | undefined

    The first matching ListNode, undefined if no match.

getAll

  • Returns an array of all encountered elements with matching value.

    Parameters

    • value: T

      The tested value.

    Returns ListNode<T>[]

    An array of matching elements.

has

  • has(value: T): boolean
  • Checks whether a value is present in the list.

    Parameters

    • value: T

      The tested value.

    Returns boolean

    true if the value is found, false otherwise

insertAfter

  • Inserts a value after a ListNode. It fails if it does not belong to the list.

    Parameters

    • value: T

      The value to be inserted.

    • after: ListNode<T>

      The target ListNode.

    Returns ListNode<T> | undefined

    The inserted ListNode, or undefined if the insertion failed.

insertBefore

  • Inserts a value before a ListNode. It fails if it does not belong to the list.

    Parameters

    • value: T

      The value to be inserted.

    • before: ListNode<T>

      The target ListNode.

    Returns ListNode<T> | undefined

    The inserted ListNode, or undefined if the insertion failed.

map

  • Applies a transformation on each element and returns a new List. The original List remains unaltered.

    Type parameters

    • U

    Parameters

    Returns List<U>

    The new List

pop

  • Removes the last element of the list.

    Returns ListNode<T> | undefined

    The removed ListNode or undefined if nothing was removed.

push

  • Adds a ListNode with input value at the end of the list.

    Parameters

    • value: T

      The value attached to the element.

    Returns ListNode<T>

    The added ListNode.

reduce

  • reduce<U>(callback: ListReducer<T, U>, initialValue: U): U
  • Accumulates the result of specific operation on each value and returns the accumulation as a single result. The original List remains unaltered.

    Type parameters

    • U

    Parameters

    • callback: ListReducer<T, U>

      The filter function.

    • initialValue: U

    Returns U

    The new List.

shift

  • Removes the first element of the list.

    Returns ListNode<T> | undefined

    The removed element or undefined if nothing was removed.

toArray

  • toArray(): T[]
  • Creates an array from the List values.

    Returns T[]

    The array of List values.

unshift

  • Adds an element with input value at the front of the list.

    Parameters

    • value: T

      The value attached to the element.

    Returns ListNode<T>

    The added element.

Generated using TypeDoc