Click to See Complete Forum and Search --> : Stacks?
A stack is kind of like a pile of dishes:
When you put one on, that will be the first taken off:
3rd put on.
2nd put on.
1st put on.
As you can see, the third is on top.
Push something onto stack:
4th put on.
3rd put on.
2nd put on.
1st put on.
Pop something off the stack:
stack: Value returned:
3rd put on. 4th put on.
2nd put on.
1st put on.
factor777
Feb 17th, 2001, 02:15 PM
ok thats a bit more clearer now.
what would be the purpose of such a way as stacking?
I just would not know waer to apply this method too.
would it be used around true conditions or what?
parksie
Feb 20th, 2001, 04:54 PM
Stacks are useful for recursion. To totally understand how they apply to this you need to know how C uses return values. The return value is stored in the register EAX on the processor. Each time you call the function, it pushes it onto a stack, so that you "unwind" the stack to go back through the functions collecting the return values in order.
stacks in general as a data structure.
parksie
Feb 21st, 2001, 12:18 PM
The STL has a stack template.
HarryW
Feb 21st, 2001, 08:33 PM
STL has a lot of handy templates doesn't it? A list template too, if I remember. I don't suppose there's a tree template too? And a queue?
parksie
Feb 22nd, 2001, 05:21 AM
I don't think it has a specific tree, but you can get make one by using list<list<int> > or similar (remembering the space between > and >).
There is a queue, and also something called priority_queue which is a sorted queue.
HarryW
Feb 22nd, 2001, 08:10 AM
Cool. Easier to make your own tree class I think. Any other natty ADTs that the STL provides that I should know about?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.