main.cpp
/// <summary>
/// This function deletes the first node in the singly linked list which matches the given date and time.
/// If there are multiple nodes which match the given moment in the list, only the first occurenct will be deleted.
/// </summary>
/// <param name="moment"></param>

This function deletes the first node in the singly linked list which matches the given date and time.
If there are multiple nodes which match the given moment in the list, only the first occurenct will be deleted.
This function deletes the first node in the singly linked list which matches the given date and time . If there are multiple nodes which match the given moment in the list only the first occurenct will be deleted .
void deleteFirstOccurence(struct moment *moment) {
	struct measurement *nodeBefore;
	if (head != NULL) {
		if (areEqual(&head->moment, moment)) {
			deleteFirstElement();
		}
		else
		{
			nodeBefore = head;
			while (nodeBefore->next != NULL && !areEqual(&nodeBefore->next->moment, moment)) {
				nodeBefore = nodeBefore->next;
			}
			if (nodeBefore->next == NULL) {
				return;
			}
			if (areEqual(&nodeBefore->next->moment, moment)) {
				struct measurement *nodeToDelete = nodeBefore->next;
				nodeBefore->next = nodeToDelete->next;
				free(nodeToDelete);
			}
		}
	}
}
void deleteFirstOccurence ( struct moment * moment ) { struct measurement * nodeBefore ; if ( head != NULL ) { if ( areEqual ( & head -> moment , moment ) ) { deleteFirstElement ( ) ; } else { nodeBefore = head ; while ( nodeBefore -> next != NULL && ! areEqual ( & nodeBefore -> next -> moment , moment ) ) { nodeBefore = nodeBefore -> next ; } if ( nodeBefore -> next == NULL ) { return ; } if ( areEqual ( & nodeBefore -> next -> moment , moment ) ) { struct measurement * nodeToDelete = nodeBefore -> next ; nodeBefore -> next = nodeToDelete -> next ; free ( nodeToDelete ) ; } } } }
<summary>
This function deletes the first node in the singly linked list which matches the given date and time.
<summary > This function deletes the first node in the singly linked list which matches the given date and time .
// TODO: Implement this function! // Pointer which references the node right before the node to remove from the singly linked list. // If there's no head, there's no list at all. // Relay on the deleteFirstElement() function in case the head matches the given moment. // Once more, we need to iterate through the singly linked list. // We're looking for a node whose successors date/time (=moment) matches the moment parameters value. // Iteration stopped. There are two reasons: // Either because of we reached the end of the list... // ... or we found a node whose date/time matches the given moment parameters value. // Temporarly store a reference to the node to remove from the singly linked list. // Update the next-reference for the node just before the one to remove... // ... and finally remove the nodeToDelete.