Singly & Doubly Linked Lists in Javascript
Licensed under MIT.
- SinglyLinkedList
Singly Linked List Class
- SinglyLinkedListNode
Singly Linked List Node Class
Singly Linked List Class
Kind: global class
Insert a new node in the Singly Linked List
Kind: instance method of SinglyLinkedList
Param | Type | Description |
---|---|---|
data | * |
to be stored in the node |
Get the node at passed index
Kind: instance method of SinglyLinkedList
Returns: the node at index position
Param | Type | Description |
---|---|---|
index | Number |
of the node to be retrived |
Return the middle node of the list
Kind: instance method of SinglyLinkedList
Returns: Return the middle node of the list
Print the Singly Linked List in human readble mode
Kind: instance method of SinglyLinkedList
Insert new node in the passed index of the Singly Linked List
Kind: instance method of SinglyLinkedList
Param | Type | Description |
---|---|---|
index | Number |
of the List |
value | * |
to be stored in the node |
Removed the current head of the Singly Linked List
Kind: instance method of SinglyLinkedList
Remove node at passed index
Kind: instance method of SinglyLinkedList
Param | Type | Description |
---|---|---|
index | Number |
of the node to be removed |
SinglyLinkedList.fromValues(...values) ⇒ SinglyLinkedList
Helper function to create a SinglyLinkedList from an array of values
Kind: static method of SinglyLinkedList
Returns: SinglyLinkedList
- Singly Linked List created
Param | Type | Description |
---|---|---|
...values | any |
data values of each node |
Singly Linked List Node Class
Param | Type | Description |
---|---|---|
value | * |
of the node to be stored |
next | SinglyLinkedListNode |
node to be pointed |
- DoublyLinkedList
Doubly Linked List Class
- DoublyLinkedListNode
Doubly Linked List Node Class
Doubly Linked List Class
Kind: global class
- DoublyLinkedList
- instance
- static
Get the node at passed index
Kind: instance method of DoublyLinkedList
Returns: the node at index position
Param | Type | Description |
---|---|---|
index | Number |
of the node to be retrived |
The push() mehod add new node to the end of the Doubly Linked List
Kind: instance method of DoublyLinkedList
Returns: the new Doubly Linked List with the new last node
Param | Type | Description |
---|---|---|
value | * |
of the new node |
The pop() method removes the last element from the Doubly Linked List
Kind: instance method of DoublyLinkedList
Returns: the new Doubly Linked List without the last node
The shift() method removes the first element from the Doubly Linked List
Kind: instance method of DoublyLinkedList
Returns: the new Doubly Linked List without the first node
The unshift() method adds the new node to the head of the current Doubly Linked List
Kind: instance method of DoublyLinkedList
Returns: the new Doubly Linked List with the new head node
Param | Type | Description |
---|---|---|
val | * |
Value of the new node |
Print the Doubly Linked List in human readble mode
Kind: instance method of DoublyLinkedList
DoublyLinkedList.fromValues(...values) ⇒ DoublyLinkedList
Helper function to create a DoublyLinkedList from an array of values
Kind: static method of DoublyLinkedList
Returns: DoublyLinkedList
- Doubly Linked List created
Param | Type | Description |
---|---|---|
...values | any |
data values of each node |
Doubly Linked List Node Class
Param | Type | Description |
---|---|---|
value | * |
of the node to be stored |
Andrea Oboe |
info@andreaoboe.com |
🔥 |
Licensed under MIT.