Пример #1
0
CircleListNode *CircleList_DeleteNode(CircleList *list, CircleListNode *node)    //O(n)
{
	TCircleList *slist = (TCircleList *)list;
	CircleListNode *ret = NULL;
	int i = 0;

	if(slist != NULL)
	{
		CircleListNode *current = (CircleListNode *)slist;

		for(i = 0; i < slist->length; i++)
		{
			if(current->next == node)
			{
				ret = current->next;
				break;
			}

			current = current->next;
		}

		if(ret != NULL)
		{
			CircleList_Delete(slist, i);
		}
	}

	return ret;
}
Пример #2
0
CircleListNode * CircleList_DeleteNode(CircleList *list, CircleListNode * node )
{
	CircleListNode *ret = NULL;

	if ( list != NULL ) {
		int i;
		CircleListNode * cur = (CircleListNode*)list;
		for (i=0; i<list->length; i++) {
			if ( cur->next == node ){
				ret = cur->next;
				break;
			}
			cur = cur->next;
		}
		
		if ( ret != NULL )
			CircleList_Delete(list, i);
	}

	return ret;
}