/* LinkedListDeleteVoid: searches for to_remove and if finds, removes */
int LinkedListRemoveVoid(LINKED_LIST *ll, foint to_remove)
{
	LINKED_LIST_NODE *prev = NULL, *curr = ll->first;

	/* if we're first... */
	if(ll->first == NULL)
	{
		return FALSE;
	}
	if(curr == to_remove)
	{
		LinkedListNext(ll);
		return TRUE;
	}
	/* else ... */
	while((curr != NULL) && (curr != to_remove))
	{
		prev = curr;
		curr = curr->next;
	}

	/* end of the list...not found */
	if (curr == NULL)
	{
		return FALSE;
	}

	/* set the two in the middle to point properly */
	prev->next = curr->next;
	/* remove curr */
    free(curr);

	if (curr == ll->last)
	{
		ll->last = prev;
	}

	ll->n--;

	return TRUE;
}
Exemple #2
0
DictionaryNode* DictionaryNext(Dictionary* dictionary){
	DictionaryNode* node = (DictionaryNode*)LinkedListNext(dictionary->linkedList);
	return node;
}