parser/src/LinkedListAPI.c
void* deleteDataFromList(List* list, void* toBeDeleted){
	if (list == NULL || toBeDeleted == NULL){
		return NULL;
	}
	
	Node* tmp = list->head;
	
	while(tmp != NULL){
		if (list->compare(toBeDeleted, tmp->data) == 0){
			//Unlink the node
			Node* delNode = tmp;
			
			if (tmp->previous != NULL){
				tmp->previous->next = delNode->next;
			}else{
				list->head = delNode->next;
			}
			
			if (tmp->next != NULL){
				tmp->next->previous = delNode->previous;
			}else{
				list->tail = delNode->previous;
			}
			
			void* data = delNode->data;
			free(delNode);
			
			(list->length)--;

			return data;
			
		}else{
			tmp = tmp->next;
		}
	}
	
	return NULL;
}
/** Removes data from from the list, deletes the node and frees the memory,
 * changes pointer values of surrounding nodes to maintain list structure.
 * returns the data 
 * You can assume that the list contains no duplicates
 *@pre List must exist and have memory allocated to it
 *@post toBeDeleted will have its memory freed if it exists in the list.
 *@param list - a pointer to the List struct
 *@param toBeDeleted - a pointer to data that is to be removed from the list
 *@return on success: void * pointer to data  on failure: NULL
 **/
Removes data from from the list, deletes the node and frees the memory,
changes pointer values of surrounding nodes to maintain list structure.
returns the data
You can assume that the list contains no duplicates
@pre List must exist and have memory allocated to it
@post toBeDeleted will have its memory freed if it exists in the list.
@param list - a pointer to the List struct
@param toBeDeleted - a pointer to data that is to be removed from the list
@return on success: void * pointer to data  on failure: NULL
Removes data from from the list deletes the node and frees the memory changes pointer values of surrounding nodes to maintain list structure . returns the data You can assume that the list contains no duplicates @pre List must exist and have memory allocated to it @post toBeDeleted will have its memory freed if it exists in the list . @param list - a pointer to the List struct @param toBeDeleted - a pointer to data that is to be removed from the list @return on success : void * pointer to data on failure : NULL
void* deleteDataFromList(List* list, void* toBeDeleted){
	if (list == NULL || toBeDeleted == NULL){
		return NULL;
	}
	Node* tmp = list->head;
	while(tmp != NULL){
		if (list->compare(toBeDeleted, tmp->data) == 0){
			Node* delNode = tmp;
			if (tmp->previous != NULL){
				tmp->previous->next = delNode->next;
			}else{
				list->head = delNode->next;
			}
			if (tmp->next != NULL){
				tmp->next->previous = delNode->previous;
			}else{
				list->tail = delNode->previous;
			}
			void* data = delNode->data;
			free(delNode);
			(list->length)--;
			return data;
		}else{
			tmp = tmp->next;
		}
	}
	return NULL;
}
void * deleteDataFromList ( List * list , void * toBeDeleted ) { if ( list == NULL || toBeDeleted == NULL ) { return NULL ; } Node * tmp = list -> head ; while ( tmp != NULL ) { if ( list -> compare ( toBeDeleted , tmp -> data ) == 0 ) { Node * delNode = tmp ; if ( tmp -> previous != NULL ) { tmp -> previous -> next = delNode -> next ; } else { list -> head = delNode -> next ; } if ( tmp -> next != NULL ) { tmp -> next -> previous = delNode -> previous ; } else { list -> tail = delNode -> previous ; } void * data = delNode -> data ; free ( delNode ) ; ( list -> length ) -- ; return data ; } else { tmp = tmp -> next ; } } return NULL ; }
Removes data from from the list, deletes the node and frees the memory,
 changes pointer values of surrounding nodes to maintain list structure.
Removes data from from the list deletes the node and frees the memory changes pointer values of surrounding nodes to maintain list structure .
//Unlink the node
