Does anyone know if it\'s possible to merge two lists (or any collection) in constant time in Java ?
http://www.cppreference.com/wiki/stl/list/splice
It\'s s
If it's easy to do with a linked list in C, then I'd guess that the LinkedList class offers the same performance
All of the operations perform as could be expected for a doubly-linked list. Operations that index into the list will traverse the list from the beginning or the end, whichever is closer to the specified index.
List list1 = new LinkedList();
list1.add(...);
List list2 = new LinkedList();
list2.add(...);
list1.addAll(list2);
edit: Nevermind. Looks like LinkedList.addAll(Collection) invokes LinkedList.addAll(int, Collection) which iterates through the new collection.