Exemplo n.º 1
0
void TheMinAndTheMax(IntNode *theList) {
	int a, min;
	int j = 0;
	int InMin = 0;
	int InMax = 0;
	int RemovedAtIndex = 0;
	a = CountList(theList);
	for (int j = 0; j < a; j++) {

		IntNode *TheMinNode = NodeAtIndex(theList, InMin);
		min = NodeAtIndex(theList, InMin)->value;

		for (int k = InMin; k < a; k++)
		{

			if (min >= TheMinNode->value)
			{
				min = TheMinNode->value;
				RemovedAtIndex = k;
			}

			TheMinNode = TheMinNode->nextNode;

		}

		InsertNode(theList, RemovedNode(theList, RemovedAtIndex), InMin);
		InMin++;

	}
	printf("Edited list\n\n");
	doPrintList(theList);
}
Exemplo n.º 2
0
status_t ArpIndexedList::pRemoveNode(ArpIndexedNode *node)
{
	assert(node != 0);
	int32	hash = HashForIndex(node->Index());
	if (! HashExists(hash)) return B_ERROR;
	if (chain[hash] == 0) return B_ERROR;

	if (node == chain[hash]) {
		status_t	answer;
		ArpIndexedNode	*unusedVar;
		answer = pRemoveChainHeadAt(hash, &unusedVar);
		if (answer != B_OK) return answer;
	}

	RemovingNode(node);
	node->RemoveNode();
	RemovedNode(node);
	return B_OK;
}