UNPKG

@node-dlc/core

Version:
31 lines (30 loc) 900 B
import { LinkedListNode } from './LinkedListNode'; /** * Implementation of a doubly linked-list that maintains both head and tail. * Tail maintenance allows for O(1) insertions at tail */ export declare class LinkedList<T> { length: number; head: LinkedListNode<T>; tail: LinkedListNode<T>; /** * Adds a node to the end of a linked List * @param T value * @returns {LinkedListNode} */ add(value: T): LinkedListNode<T>; /** * Finds the node at a specific position */ valueAt(index: number): T; /** * Finds the node for the index or throws an out of range exception */ nodeAt(index: number): LinkedListNode<T>; /** * Removes the node at the index and returns its value. * Head or tail removal is an O(1) operation. For removal of other indexes * is at worst O(N). */ remove(index: number): T; }