Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DoublyLinkedList

Hierarchy

  • DoublyLinkedList

Index

Constructors

constructor

  • Call to create the DLL and to optionally pass in a item to be added to the DLL head.

    Parameters

    • Default value value: any = null

    Returns DoublyLinkedList

Properties

Private head

head: LinkedListNode<any> | null = null

Private size

size: number = 0

Private tail

tail: LinkedListNode<any> | null = null

Methods

addToHead

  • addToHead(value: any): void

addToTail

  • addToTail(value: any): void

forEach

  • Call this function when you want to iterate through the entire list of items.

    throws

    {Error} if this DLL is empty

    Parameters

    • cb: (item: any) => {}

      call back function

        • (item: any): {}
        • Parameters

          • item: any

          Returns {}

    Returns Promise<IterationComplete>

forEachReverse

  • Call this function to iterate through the list of items in reverse.

    throws

    {Error} if this DLL is empty.

    Parameters

    • cb: (item: any) => {}

      call back function

        • (item: any): {}
        • Parameters

          • item: any

          Returns {}

    Returns Promise<IterationComplete>

forSome

  • Call this function when you want to iterate through the items in the linked list but don't want to iterate through all of them.

    Return true in the callback to stop this function from continuing to iterate through the items.

    throws

    {Error} if this DLL is empty.

    Parameters

    • cb: (item: any) => {}

      callback function

        • (item: any): {}
        • Parameters

          • item: any

          Returns {}

    Returns Promise<IterationComplete>

getSize

  • getSize(): number

removeFromHead

  • removeFromHead(): null | any
  • Returns the value of the head node. Null if doesn't exist.

    Returns null | any

    value of the node at the head

removeFromTail

  • removeFromTail(): null | any
  • Returns the value of the tail node. False if doesn't exist.

    Returns null | any

    value of the node at the tail

Generated using TypeDoc