Lab5/nodeOperations.cpp
void nodeOperations::bringToBack(Link node){
	Link previousPtr, currentPtr;
	previousPtr = NULL;
	currentPtr = sPtr;
	//Brings us to the correct position in the list for this item.
	if (DEBUG){
		printf("The node %d is about to move into place\n", node->getPacketID());
	}
	while (currentPtr != NULL){
		previousPtr = currentPtr;
		currentPtr = currentPtr->getNext();
	}
	//Are we at the beginning?
	if(previousPtr == NULL){
		node->setNext(NULL);
		sPtr = node;
	}
	//Now we're adding it to the end in the list
	else{
		previousPtr->setNext(node);
		node->setNext(NULL);
	}
}
//Brings the node to the back of the linkedlist given the node and the starting process.
Brings the node to the back of the linkedlist given the node and the starting process.
Brings the node to the back of the linkedlist given the node and the starting process .
void nodeOperations::bringToBack(Link node){
	Link previousPtr, currentPtr;
	previousPtr = NULL;
	currentPtr = sPtr;
	if (DEBUG){
		printf("The node %d is about to move into place\n", node->getPacketID());
	}
	while (currentPtr != NULL){
		previousPtr = currentPtr;
		currentPtr = currentPtr->getNext();
	}
	if(previousPtr == NULL){
		node->setNext(NULL);
		sPtr = node;
	}
	else{
		previousPtr->setNext(node);
		node->setNext(NULL);
	}
}
void nodeOperations :: bringToBack ( Link node ) { Link previousPtr , currentPtr ; previousPtr = NULL ; currentPtr = sPtr ; if ( DEBUG ) { printf ( " \n " , node -> getPacketID ( ) ) ; } while ( currentPtr != NULL ) { previousPtr = currentPtr ; currentPtr = currentPtr -> getNext ( ) ; } if ( previousPtr == NULL ) { node -> setNext ( NULL ) ; sPtr = node ; } else { previousPtr -> setNext ( node ) ; node -> setNext ( NULL ) ; } }
Brings the node to the back of the linkedlist given the node and the starting process.
Brings the node to the back of the linkedlist given the node and the starting process .
//Brings us to the correct position in the list for this item. //Are we at the beginning? //Now we're adding it to the end in the list