Quote:
Originally posted by LoveJones
I'm sorry guys, I've actually done research in this area. We compared a vector implementation of a stack to a dynamically allocated array and the array smoked the vector. We took a look into the STL and one conditional was making the difference (in the vector). The times were something like 1.5 for the array and 20+ for the vector given 100,000 inputs (inserts).
No information as to what you mean by "inserts" or what you mean by "a conditional". I have never seen a degradation of speed as you suggested, unless you are comparing apples to bananas.
You say a "stack" implementation. As others suggested, did you use "reserve" to preallocate the memory up front for the vector?
Quote:
I've never liked the STL due to it being slow and I'm telling you first hand that I have seen the numbers.
I've also seen "the numbers", and again, I have never seen any degradation that you speak of, unless you coded the vector implementation of your code very poorly, or did not take advantage of the functions that make vector operations such as "push_back" speedy. Also, if you are using a stack, what is wrong with std::stack? Why didn't you use a std::deque? Maybe you used the wrong STL container for your purposes.
Quote:
That of course does not mean that vector does not have it's own applications and it's own niches,
It isn't a "niche" anymore, it is one of the standard containers.
Quote:
but in my experience if you are looking to minimize overhead (in terms of coding not in memory) using your own dynamic array >> vector.
Many professionals and C++ experts disagree wholeheartedly with this statement.
Quote:
I'd be happy to share the code with you all if I can find it on my Linux box.
Please do.
Regards,
Paul McKenzie