Answers for "c++ linked list clear"

C++
1

c++ linked list clear

void llDeleteNode(List &list, Node* node)
{
	if(list == node)
		list = llNext(list);
	else
	{
		List temp = list;
		while (llNext(temp) != node)
			temp = llNext(temp);

		temp->next = node->next;
	}

	delete node;
}

void llClear(List &list)
{
	while(list != NULL)
		llDeleteNode(list, list);
}
Posted by: Guest on March-25-2021

Browse Popular Code Answers by Language