Algorithms: C++: Data Structures, Automation & Problem Solving, w Programming & Design (app design, app development, web development, web design, jquery, ... software engineering, r programming) by Code Well Academy & R.M.Z. Trigo

Algorithms: C++: Data Structures, Automation & Problem Solving, w Programming & Design (app design, app development, web development, web design, jquery, ... software engineering, r programming) by Code Well Academy & R.M.Z. Trigo

Author:Code Well Academy & R.M.Z. Trigo [Trigo, R.M.Z.]
Language: eng
Format: epub
Published: 2015-07-19T22:00:00+00:00


Array Queue: Dequeue() Function

The Dequeue() method from an Array Queue removes an item from that queue. The function returns that item as the Function Output. It does this in the following procedure, in this particular order:

1) Check the Array Count if there are any items to dequeue

2) If not, either return NULL or report a queue underflow error

3) If there’s an item to dequeue, create a Local Variable. Set it to be your return item (it should be the item at the front of the queue!). Remove the item at the Front of the Queue afterwards

4) Increment the Front Index. If the Front Index becomes bigger than or equal to the Array Size, set the Front Index to 0 (it’s now at the start of the Circular Array).

5) Decrement the Item Count

6) And Finally, the function returns your item and ends.

After the dequeue() procedure successfully removes and retrieves an item, the item should be the first item from the array. Also, the item count should be decreased by 1.

Remember: function returns should be the very last thing in a function procedure - as it ends the function.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.