javascript-algorithms
javascript-algorithms copied to clipboard
set tail as newNode if currentNode is the tail
closes #1016 closes #1004
To reproduce
- Populate the list normally, insert few values.
- call insert with
rawIndexequals to last node index + 1 (exactly where new node would fit)
Expectation
this.tail should point to the last added value as it has rawIndex as previous tail + 1
Behaviour
this.tail points to the previous tail.
Fix
If currentNode is the tail then newNode should be the new tail, as in this scenario currentNode will have newNode as its next