Just trying to get my head around linked lists and I'm trying to all the standard container functions..
For a singly-linked list are these algorithms correct?
void pop_front(const T& t)
{
// Deallocate memory pointed to by head
node<T>* tempNode = head;
delete head;
// Get new head
head = tempNode->next;
}
void pop_back(const T& t)
{
// Deallocate memory pointed to by tail
delete tail;
// Get new tail
node<T>* currentNode = head;
for (size_t i=0; i<sizet-2; i++)
{
currentNode = currentNode->next;
}
tail = currentNode;
tail->next = NULL;
}
Cheers!