Skip to content

Instantly share code, notes, and snippets.

@wallstop
Created September 2, 2013 04:37
Show Gist options
  • Save wallstop/6409245 to your computer and use it in GitHub Desktop.
Save wallstop/6409245 to your computer and use it in GitHub Desktop.
template<typename T>
LinkedList<T>::LinkedList()
{
head = new node;
tail = new node;
head->prev = 0; //This can also be null, same thing.
head->next = tail;
tail->next = 0;
tail->prev = head;
// From here on out, you keep everything in between head and tail,
// and never change what head and tail point to. This is useful for
// iterating, as you can check when you've reached the beginning /
// end of the list, because you always know where those places are!
// (head and tail, respectively)
current = NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment