|
-
Feb 17th, 2001, 02:32 PM
#1
A stack is kind of like a pile of dishes:
When you put one on, that will be the first taken off:
Code:
3rd put on.
2nd put on.
1st put on.
As you can see, the third is on top.
Code:
Push something onto stack:
4th put on.
3rd put on.
2nd put on.
1st put on.
Code:
Pop something off the stack:
stack: Value returned:
3rd put on. 4th put on.
2nd put on.
1st put on.
-
Feb 17th, 2001, 03:15 PM
#2
Member
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?
-
Feb 20th, 2001, 05:54 PM
#3
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 21st, 2001, 06:32 AM
#4
stacks in general as a data structure.
-
Feb 21st, 2001, 01:18 PM
#5
Monday Morning Lunatic
The STL has a stack template.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 21st, 2001, 09:33 PM
#6
Frenzied Member
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?
Harry.
"From one thing, know ten thousand things."
-
Feb 22nd, 2001, 06:21 AM
#7
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 22nd, 2001, 09:10 AM
#8
Frenzied Member
Cool. Easier to make your own tree class I think. Any other natty ADTs that the STL provides that I should know about?
Harry.
"From one thing, know ten thousand things."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|