//Clears the Linked List
void LinkedList :: clear()
{
    
    if(!isEmpty())                  /*If the linked list is not empty than we start removing elements from the back*/
    {
        removeFromBack();
    }
    
}
Beispiel #2
0
MusicRec * removeFromBack( MusicRec * theList )
{
	MusicRec * returnVal;

	if ( isEmpty( theList ) == true ) {
		return NULL;
	}

	if ( theList->next != NULL ) {
		returnVal = removeFromBack( theList->next );
	} else if ( theList->next == NULL ) {
		return NULL;
	}
	if ( returnVal ==  NULL ) {
		returnVal = theList->next;
		theList->next = NULL;
	}

	return returnVal;
}
LinkedList::~LinkedList(){ //destructor
    while(!isEmpty()) //if list is not empty
        removeFromBack();
}
void LinkedList::clear(){ //same as destructor
    while(!isEmpty()) //if list is not empty
        removeFromBack();
}