Stack
Everyone should know the concept and operation of a stack by now. We encountered stack data structures when discussing call stacks and evaluation stacks.
Stacks are last-in, first-out (LIFO) collections. Compare it to a stack of books where it’s (nearly) impossible to get a book other than the one at the top without popping the books on top of it off the stack first. The basic operations are called Push
and Pop
, and a Peek
method allows looking at the top element without popping it off. Figure 16.4 graphically depicts the operation of a stack.
To illustrate the use of a stack, take a look ...
Get C# 5.0 Unleashed 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.