Can you tell me which basic operations on a list can cause an use of stack proportional to the size of the list? (I mean, looping on all elements...)

I have problems with stack size.

Is iterator post-incrementing dangerous in this sense?

Recommended Answers

All 5 Replies

Can you tell me which basic operations on a list can cause an use of stack proportional to the size of the list? (I mean, looping on all elements...)

I have problems with stack size.

Is iterator post-incrementing dangerous in this sense?

Could you make your question clearer? Which Stack are you referring to? Do you mean STL's std::stack , or something of your own creation? Or do you mean a stack, implemented as a linked list?

Do you mean STL's std::stack , or something of your own creation?

As he's talking about iterators, I assume he means the stack template from STL :)

As he's talking about iterators, I assume he means the stack template from STL :)

Yeah, I see what you mean, but I wanted to make sure, because some people use incorrect terminology (he might have used the word "iterator" in place of "Index", as in Array index etc)

Can you tell me which basic operations on a list can cause an use of stack proportional to the size of the list? (I mean, looping on all elements...)
I have problems with stack size.
Is iterator post-incrementing dangerous in this sense?

No need in recursive implementation of basic list operations. Overloaded pre- and postincrement of list iterators have absolutely straitforward codes, I can't imagine stack-consumed implementation of these operators.

Can you present "bad" code fragment?

It's an embedded software application.

There are many loops on all elements of a very big list which (maybe) consumes all the stack reserved for its task.

Indeed, I have the Program Counter in stl_list.h

----------------------
operator->() const
{ return &static_cast<_Node*>(_M_node)->_M_data; }
----------------------

I don't want you to investigate it... just only if you know problematic issues again list and stack use.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.