// Remove first node that contains the given data void *removeIfExists(List* list, void* data) { ListNode *element = list->head; while ((element != NULL) && (element->data != data)) { element = element->next; } if (element != NULL) { data = unlinkElement(list, element); } return data; }
// remove element at index (0-indexed) void *removeElement(List *list, int index) { void *data = NULL; if (index >= list->num_nodes) { return data; } ListNode *element = NULL; int i = 0; element = list->head; while (i++ < index) { element = element->next; } data = unlinkElement(list, element); return data; }
void deleteElement (Element *element) { unlinkElement(element); discardElement(element); }
void requeueElement (Element *element) { unlinkElement(element); enqueueElement(element); }