As title suggests, I had problems with a program of mine where I used a std::list as a stack and also to iterate over all elements of the list. The program was taking way to
[Edit: I stand corrected. std::list doesn't have operator[]. Sorry.]
It's hard to tell from your description, but I suspect you were trying to access the items randomly (i.e., by index):
for(int i = 0; i < mylist.size(); ++i) { ... mylist[i] ... }
Instead of using the iterators:
for(list::iterator i = mylist.begin(); i != mylist.end(); ++i) { ... (*i) ... }
Both "vector" & "deque" are good at random access, so either will perform adequately for those types---O(1) in both cases. But "list" is not good at random access. Accessing the list by index would take O(n^2) time, versus O(1) when using iterators.