Like this article? We recommend
Removing Items from the Queue
Listing 4 shows the code for removing items from the queue.
Listing 4 Removing Queue Items
const QueueElementPtr NMSServiceQueue::remove(void) { QueueElementPtr tempQueueItem; QueueElementPtr nextQueueItem; if (queueIsEmpty()) { return NULL; } else { tempQueueItem = startOfQueue; nextQueueItem = startOfQueue->nextQueueElement; if (nextQueueItem != NULL) startOfQueue->nextQueueElement = nextQueueItem; startOfQueue = tempQueueItem->nextQueueElement; return tempQueueItem; } }
As for Listing 3, Listing 4 updates the two variables startOfQueue and endOfQueue in conjunction with items being removed from the queue.