Re: Generics question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

Not too sure what level you're coming at this from, so If I've
oversimplified my apologies.

A stack is a bit like an array, but you can only get at the "first"
element - the top of the stack.

For example, If I push these strings on to a stack : "one", "two", "three",
"four" the stack looks like this :

"four" <--- top of the stack
"three"
"two"
"one"

If I now perform a Pop on the stack I get "four" back and the stack looks
like this :

"three" <---- top of the stack
"two"
"one"

If I then push "five" on to the stack it looks like this :

"five" <---- top of the stack
"three"
"two"
"one"

And "five" is what you get if you perform a pop. So you'd use a stack to
queue up objects when it was important to always get the most recently
queued object. They can also be called a LIFO queue - Last In First Out.

HTH,

Adam
==========


.



Relevant Pages

  • Re: Statement on Schildt submitted to wikipedia today
    ... Please segment your replies, Peter. ... So far as I can tell, you essentially need some kind of LIFO queue ... you need a stack. ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: Please simply answer this question and dont second guess my reason for asking it
    ... LIFO Queue ... accustomed to a stack? ... I believe the operative word here is "sneakerful". ... Tux rox! ...
    (comp.os.linux.development.apps)
  • Re: Doc/View question
    ... elements in the array to get how many bytes of stack space it requires. ... sequence of bytes that is long enough to hold the entire contents of the array. ... data type" for this purpose! ... So then it appears that I can put structs of different member types into CArray ...
    (microsoft.public.vc.mfc)
  • Re: I dont understand the definition of DOES>
    ... on stack on code entry). ... You can use DOES to make ARRAY and then use ARRAY ... CREATE CELLS ALLOT ... First you'd make the code that will execute on the child word. ...
    (comp.lang.forth)
  • Re: a kind of an assumed-shape array leads to a sig11
    ... extent of an array in a subroutine bad practice? ...    end module bar ... default stack size limits on many current systems. ... Some compilers have options to avoid putting large automatic arrays ...
    (comp.lang.fortran)