473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to walk through a Stack without destroying it?

Since stack does not provide iterator interfaces, how to iterate
over it (e.g., print out each element in it for debug purpose) without
changing its structure or copying the whole stack to another stack for such
purpose?

Thanks a lot.

-Andrew
Jul 22 '05 #1
2 8706
Andrew wrote:

Since stack does not provide iterator interfaces, how to iterate
over it (e.g., print out each element in it for debug purpose) without
changing its structure or copying the whole stack to another stack for such
purpose?


If you need operations that aren't supported by a stack don't use a
stack. vector or deque might be what you need.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #2

"Andrew" <ha****@ureach.com> wrote in message
news:11**************************@posting.google.c om...
Since stack does not provide iterator interfaces, how to iterate
over it (e.g., print out each element in it for debug purpose) without changing its structure or copying the whole stack to another stack for such purpose?


A stack is just a thin wrapper around another container. The point of
using a stack is to make your code self-documentating --to emphasize
that you don't need to use the other operations supported by the
underlying container. So if this last condition is not satisfied,
there's no reason to use a stack.

Jonathan
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael G. Schneider | last post by:
I know that using Word Automation inside an ASP page is no good idea. Anything I want to do in the current project is: open document, change some text, save and close document. Basically changing...
20
by: Sushil | last post by:
Hi gurus I was reading FAQ "alloca cannot be written portably, and is difficult to implement on machines without a conventional stack." I understand that the standard does not mandate...
26
by: bahadir.balban | last post by:
Hi, When you define varibles in the middle of your function call (C99), such as: if(i == 5) { int x = 5; int z = 2; }
1
by: vermeulen | last post by:
Hi I've been happily using visual studio 2003 7.1 for quite awhile now without major problems. However, in the past few weeks I've become very angry at the debugger. The problem is that I cannot...
5
by: srikanth | last post by:
is it possible not to decrement the top variable after we remove(or retreive) a file from a stack >MY IDEA is:> if top is not decremented the stack is like it has some files existing in it with...
7
by: DevNull | last post by:
Hello everyone, I decided to pick c++ back up after not really having used it much in 10 years. Just as a point of refference, there was no standard C++ last time I used regularly. Anyways...
1
by: shashankjoshisam | last post by:
can anybody tell me how to reverse a stack without using any big and variable sized memory block(not to use any other stack which is equal to the given stack in size). I have tried but could not...
87
by: CJ | last post by:
Hello: We know that C programs are often vulnerable to buffer overflows which overwrite the stack. But my question is: Why does C insist on storing local variables on the stack in the first...
3
thatos
by: thatos | last post by:
Is the any other way to remove contents of a stack without using the following loop or is there any other way to remove stack contents? Here is the loop Stack s = new Stack(); . . . . ....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.