Original Post
Hello, I'm messing around with linked lists in "Nibbles" type game I'm making and I've run into a problem. I'm wanting to join two caterpillars together, in other words, concatenating one linked list to the end of another. My lists are set up so that the first node is private and there is a method to add nodes to the beginning of the list only. They aren't java LinkedLists or anything of that sort, my class is completely home made. I have a concat method as follows: I thought about converting them both to arrays, concatenating using memory copy commands and then reconstructing a new linked list from this array, since one of my constructors for the linked list takes an array of objects (segments) and constructs a linked list perfectly. Anyway, didn't know if any of you had a good algorithm for linked list concatenation, but I thought I'd ask anyways. Thanks, toXic1337~
public void concat(LinkedList other)
{
//go to the end of private variable first and add
//other to the end of it, in other words, find last.next
//and set it equal to others first node.
}