Queue and Stack
Queues and stacks are two special types of collections that use a different access mechanism than the ones we have already discussed, where any item in the collection is accessible at any time, one way or the other.
Queues are used to model a first-in, first-out (FIFO) type of scenario, like a one-way pipe or stream. Stacks are used for, well, stacks of objects, where the next object is added “above” the previous one, and needs to be removed before the ones underneath it. This scenario is a last-in, first-out scenario, used for example to model something like a mail in-box, where the next piece of paper thrown in sits above all the ones that were there before it.
Our example uses a queue object and two stack objects to simulate ...
Get Visual Basic® .NET by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.