Program5/packetQueue.cpp
//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 packetQueue::bringToBack(Link node){
	Link previousPtr, currentPtr;
	previousPtr = NULL;
	currentPtr = sPtr;
	if (DEBUG){
		cout << "The packet "<< node->getPacketID() << " is about to move to the back. " << endl;
	}
	while (currentPtr != NULL){
		previousPtr = currentPtr;
		currentPtr = currentPtr->getNext();
	}
	if(previousPtr == NULL){
		node->setNext(NULL);
		sPtr = node;
	}
	else{
		previousPtr->setNext(node);
		node->setNext(NULL);
	}
}
void packetQueue :: bringToBack ( Link node ) { Link previousPtr , currentPtr ; previousPtr = NULL ; currentPtr = sPtr ; if ( DEBUG ) { cout << " " << node -> getPacketID ( ) << " " << endl ; } 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