Your conclusions are incorrect.
> If you made use of push_back and pop_front with a std::vector
There is no std::vector::pop_front() function.
> then I would expect the performance to be the same as a linked list O(1).
¿why? your hypothetical `pop_front()' would be O(n)
> I was making a mistake and not using pop_front to remove the first element.
You are still not using the unexistant `pop_front()'
1 2 3 4 5
|
for (int j = 0; j < retrievecount; j++)
{
Packet p = vec_packets[0];
vec_packets.pop_back();
}
|
Your vector implementation is not a queue, but a stack.
> one million seemed to be about 3x time difference just like 50,000 was
> the linked list test was nearly 8x faster as far as appending.
> linked list was still about 4x faster than the vector on retrieval.
>> Have you changed the clock though - it won't make any difference until you do
Occam's razor. You are getting so much difference because the cuckoo in the clock died when measuring the vector's implementation.
Let's try to shot where it matters, please.
> I was running them in debug mode and for some reason this way drastically
> effecting my numbers. It turns out vectors ARE faster when using release mode.
Optimizations are quite aggressive, sometimes too much.
Still, you are measuring different things. Deleting the last element in a vector is quite an easy operation, just call one destructor and move a pointer. Deleting the first would mean to move all the other elements one position, and is quite expensive.
However you may implement a queue using vector, and it would be a lot faster than a linked list. You'll simply need to threat it as if it were a circular buffer, that way you don't need to move any elements, just adjust `front' and `end' indices.
By the way, there is `std::queue' also.
> I was unable to open the rar file - I use Linux .
Then you may want to install `unar'
> I just thought that would be some trouble for people to look at since it
> would be 5 separate files.
I recommend github for those cases.