-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
InformativeExplain a piece of CodeExplain a piece of Code
Description
While we are dequeuing items from the queue, if we reach the last item both front and rearpointing to the last item, and the front will have the value of NULL the we delete the address of rear using the temp pointer, so the rear will be pointing to nothing so it must be marked as NULL to indicate we reach the end of the queue.
this is the code snippet I'm talking about:
Datastructure_implementation/Linked Queue/LinkedQueue.h
Lines 94 to 110 in 6065aef
| ItemType dequeue() | |
| { | |
| if (isEmpty()) | |
| throw EmptyQueue(); | |
| else | |
| { | |
| NodeType* temp = front; | |
| ItemType item = front->info; | |
| front = front->next; | |
| // We reach the end and if we delete the rear will be pointing to nothing so we put it to NULL. | |
| if (front == NULL) | |
| rear = NULL; | |
| delete temp; | |
| return item; | |
| } | |
| } |
Metadata
Metadata
Assignees
Labels
InformativeExplain a piece of CodeExplain a piece of Code