I'm no data structures expert, but as I understand it linked lists have proven to be quite inefficient in most scenarios mostly due to cache misses. One of the few reasons I would ever consider using them is for the unique ability to merge/split two of them in constant time; yet the class doesn't provide such a method.
I thought, all right, I will implement my own to fit my needs. I wanted the new class to follow the Collections framework API so I had it implement and extend the very same classes the standard LinkedList did. Soon I realized that I was just recreating LinkedList and all of this was pointless. At that point I might as well just copy paste the code and add the methods that I need.
On the same note, I can't find a reason (besides perhaps thread-safety which I am far from fully grasping yet) why there isn't such a method. Everything seemed like a standard linked list implementation and a method similar to splice()
from the C++ STL could fit in there.
Am I missing something?
LinkedList<Integer> list1 = new LinkedList();
list1.add(4);
list1.add(2);
list1.add(7);
// list1 = {4 , 2 , 7}
LinkedList<Integer> list2 = new LinkedList();
list2.add(9);
list2.add(4);
list2.add(6);
// list2 = {9 , 4 , 6}
list1.join(list2); // in O(1)
// at this point list2 should be invalidated/empty
// list1 = {4 , 2 , 7 , 9 , 4 , 6}
// list2 = {}