Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone post a code?

Thanks
Posted
Comments
Dr.Walt Fair, PE 16-Jul-11 23:50pm    
Please explain what you mean. By definition a Stack is ordered by first in last out. Do you want a random access storage or what?

Uses a List<T> for that. You will have random access and it can be used like a stack by adding and removing items at the end.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-Jul-11 1:19am    
Correct, a 5. Using list as a stack can be slower than a stack though. Everything depends on ultimate requirements of operation set.
--SA
Stacks cannot be mixed, unless you pop all the items off, reorder them, and then push them back on again.
By definition, the first item pushed onto a stack is the last item out, and the last item pushed on is the first popped off.
Think of a pile of coins: you can only take the top coin off without the pile collapsing. If you want to re-order the coins, you must remove them all, and re-stack them in a different order.
 
Share this answer
 
Comments
Espen Harlinn 17-Jul-11 19:15pm    
Well answered as usual - my 5
RaisKazi 17-Jul-11 20:59pm    
To the Point. My 5.
Sergey Alexandrovich Kryukov 18-Jul-11 1:18am    
Stack is stack, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900