Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


Dave


In reply to Re: Why are "push", "pop", "shift" and "unshift" so named? by davido
in thread Why are "push", "pop", "shift" and "unshift" so named? by Cody Pendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-26 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found