Class LinkedList<T>

Class representing a singly linked list. This list structure allows insertion, search, retrieval by index, and deletion of values.

Type Parameters

  • T

    The type of values stored in the list.

Constructors

Methods

  • Deletes the first occurrence of a specified value from the list. Adjusts the head, tail, and next pointers accordingly.

    Parameters

    • value: T

      The value to delete.

    Returns void

  • Retrieves the value at a specified index. Traverses from the head up to the index if within bounds.

    Parameters

    • index: number

      The index of the value to retrieve.

    Returns T

    • The value at the specified index, or null if the index is out of bounds.
  • Inserts a new value at the end of the list. Updates the tail pointer and, if the list was empty, also sets the head.

    Parameters

    • value: T

      The value to insert.

    Returns void