A LinkedList
is a data structure consisting of a group of nodes which together represent a sequence. Each node is composed of data and a reference (in other words, a link) to the next node in the sequence.
To initialize a new linked list, instantiate the LinkedList
class:
const list = new LinkedList<number>();
Adds an element to the end of the linked list.
list.append(value: T): void;
Adds an element to the beginning of the linked list.
list.prepend(value: T): void;
Searches for an element with the given value in the linked list.
list.find(value: T): Node<T> | null;
Removes an element with the given value from the linked list.
list.delete(value: T): void;
Checks if the linked list is empty.
list.isEmpty(): boolean;
Returns a string representation of the linked list.
list.print(): string;