I always thought that push and pop applied to a "cafeteria plates" metaphor, not trays. ;) Wikipedia seems to support this assertion.
As the wikipedia article states, the cafeteria plates metaphor works because it conveys the notion of LIFO, as well as the notion that all but the top-most item are hidden from view in a traditional stack implementation as they are in a stack of cafeteria plates.
If you don't like the plates metaphor; how about those vending machines with spiral dispenser? The last item loaded is the first one to pop off as the spiral turns to dispense the item. Or how about facial tissue; the top one is always the one that pops out next as you pull on it. Of course for that metaphor to really work you would have to assure that the box of tissue was loaded from the top. ;)
Shift and unshift are perhaps a little more difficult. Since they occur at the zero end of a queue, the notion is that the entire queue has to shuffle up one for someone else to be placed in the zero position. And when one is taken from the zero position, everyone shifts down one spot. Think of a line of people. If the person at the front of the line passes through the threshold everyone else has to shift forward so that someone else can wait at the front of the line.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||