DEPRECATED-data-structures
DEPRECATED-data-structures copied to clipboard
I don't know if this comment is the proper way to ask a question, but here it goes: shouldn't we update (head.prev).next to the new Node?
https://github.com/williamfiset/data-structures/blob/068c10624abab4568433f047fd7be3f24fb40d2a/com/williamfiset/datastructures/linkedlist/DoublyLinkedList.java#L80
Yes, something seems to be missing? Haven't touched this code in a while. What I think should happen is that the current head's prev pointer should point to the new node, and the new node's next pointer should point to the current head. Then update the head pointer to be the new node. I'm surprised tests haven't caught this.
If you're up for it, can you update the code with the proper functionality and add test(s)? Also, FYI this repo was moved to the Algorithms repository so the current file to edit would be:
https://github.com/williamfiset/algorithms/blob/master/com/williamfiset/algorithms/datastructures/linkedlist/DoublyLinkedList.java
and the tests are at:
https://github.com/williamfiset/Algorithms/blob/master/javatests/com/williamfiset/algorithms/datastructures/linkedlist/LinkedListTest.java
@williamfiset , What is the status of this issue? I can update and test it out if you want.
I also got the impression that is something wrong at the first look. After taking a closer, everything seems to be correct.
Please check the previous line of code (line 79) and the constructor parameters of the new node.
For a reference:
head.prev = new Node<T>(elem, null, **head**);
head = head.prev;
@williamfiset
What is the status of this issue? I can update
As @skill-bit mentioned in above comment, there doesn't seem any issue with the current implementation.
It seems that this can be closed as 'Invalid'. @williamfiset, what do you think?