insert a new node to SinglyLinkedList.
self reference to the SinglyLinkedList
const sll = new SinglyLinkedList<number>();
ssl.insert(1, 0); // [1]
ssl.insert(2, 0); // [2, 1]
ssl.insert(3, 1); // [2, 3, 1]
The data inserted into a new node
The position of the new inserted node
Remove last element of list
self reference to the SinglyLinkedList
const sll = new SinglyLinkedList<number>();
ssl.push(1).push(2).push(3); // [1, 2, 3]
ssl.pop(); // [1, 2];
Remove first element of list
const sll = new SinglyLinkedList<number>();
ssl.push(1).push(2).push(3); // [1, 2, 3]
ssl.popStart(); // [1, 2];
Insert A node at the end
self reference to the SinglyLinkedList
const ssl = new SinglyLinkedList<number>();
ssl.push(1).push(2).push(3);
The data inserted into a new node
Insert A node at the start
self reference to the SinglyLinkedList
const sll = new SinglyLinkedList<number>();
ssl.pushStart(1); // [1]
ssl.pushStart(2); // [2, 1]
ssl.pushStart(3); // [3, 2, 1]
The data inserted into a new node
Log the content of the SinglyLinkedList.
const sll = new SinglyLinkedList<number>();
ssl.push(1).push(2).push(3); // [1, 2, 3]
ssl.view(); // 1 => 2 => 3 => null
Generated using TypeDoc
deletes a node at position
Returns
self reference to the SinglyLinkedList
Example