Linked List
Source code: https://github.com/gofhilman/linked-lists
This project creates a LinkedList class manually in JavaScript. The LinkedList class provides a dynamic data structure that allows for efficient insertion, deletion, and traversal of elements. Each node in the linked list contains a value and a reference to the next node, forming a chain-like structure.
Features
append(value)
: Adds a new node with the specified value to the end of the list.prepend(value)
: Adds a new node with the specified value to the beginning of the list.size()
: Returns the total number of nodes in the list.toHead()
: Returns the first node (head) of the list.toTail()
: Returns the last node (tail) of the list.at(index)
: Returns the node at the specified index.pop()
: Removes the last node from the list.contains(value)
: Checks if a node with the specified value exists in the list.find(value)
: Returns the index of the node with the specified value, or'
if not found.toString()
: Returns a string representation of the linked list.