linked-list-jo
v1.0.0
Published
My implementation of a linked list class.
Downloads
4
Readme
Linked List
My implementation of the linked list project from The Odin Project.
Installation
npm install linked-list-jo
Usage
import LinkedList from 'linked-list-jo';
const myLinkedList = new LinkedList();
myLinkedList.append(0)
myLinkedList.append(1)
myLinkedList.append(2)
console.log(myLinkedList.toString());
Features
append(value)
adds a new node containingvalue
to the end of the list.prepend(value)
adds a new node containingvalue
to the start of the list.size
returns the total number of nodes in the list.getHead
returns the first node in the list.getTail
returns the last node in the list.at(index)
returns the node at the givenindex
(0-based).pop
removes the last element from the list and returns it.contains(value)
returnstrue
ifvalue
is in the list and otherwise returnsfalse
.find(value)
returns the first 0-based index of the node containingvalue
, ornull
if not found.toString
represents your LinkedList objects as strings, so you can print them out and preview them in the console. The format is:( value ) -> ( value ) -> ( value ) -> null
.insertAt(value, index)
that inserts a new node withvalue
at the givenindex
.removeAt(index)
that removes the node atindex
.