Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LinkedList<T>

description

Linked lists are among the simplest and most common data structures. They can be used to implement several other common abstract data types, including lists, stacks, queues, associative arrays, and S-expressions, though it is not uncommon to implement those data structures directly without using a linked list as the basis. The principal benefit of a linked list over a conventional array is that the list elements can be easily inserted or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk, while restructuring an array at run-time is a much more expensive operation. Linked lists allow insertion and removal of nodes at any point in the list, and allow doing so with a constant number of operations by keeping the link previous to the link being added or removed in memory during list traversal.

Type parameters

  • T

Hierarchy

  • LinkedList

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Private head

head: any

Methods

add

  • add<T>(value: T): void
  • method
    description

    add method will take value as argument and store in linkedlist node

    Type parameters

    • T

    Parameters

    • value: T

      Value that will store in linkedlist node

    Returns void

delete

  • delete<T>(value: T): boolean
  • method
    description

    delete will removes the node with value and returns boolean

    Type parameters

    • T

    Parameters

    • value: T

      value that will be removed from Linkedlist

    Returns boolean

    boolean

display

  • display<T>(): T[]
  • method
    description

    Will return array of values

    Type parameters

    • T

    Returns T[]

    array

insert

  • insert<T>(value: T, position: T): void
  • method
    description

    This method will be used to insert value in a given value's position

    Type parameters

    • T

    Parameters

    • value: T

      Value

    • position: T

      Value's position where the new value going to be inserted

    Returns void

max

  • max(): T | null
  • method
    description

    Returns max value

    Returns T | null

    T

min

  • min(): T | null
  • method
    description

    Returns minimum value

    Returns T | null

    T

search

  • search<T>(value: T): boolean
  • method
    description

    Value that needs to be searched on linkedlist

    Type parameters

    • T

    Parameters

    • value: T

      Value that needs to be search

    Returns boolean

    boolean

Generated using TypeDoc