2 ms·
You should fix your code for testing the speed of the STL implementation. You intentionally chose to implement it in a scenario that discarded any previous res
by ismarc 17y ago
You should fix your code for testing the speed of the STL implementation. You intentionally chose to implement it in a scenario that discarded any previous results. The most common usage is for (std::list<x>::iterator it = list.begin(); it != list.end(); it++); Using your naive approach, of course the list is going to be slow to access each element. Keeping a single pointer in memory is much more efficient than spending clock cycles going back over elements you've already seen.
If you need the random access, or 32 bits is excessive to keep in memory (for whatever reason), a deque exists specifically for the purpose.