queue vs deque

Hi all!

I am sorry if this is a very basic question.

I am developing a code that needs a FIFO container. At the beginning I was using a std:queue, but because I also need to remove elements I have to use a std::deque.

Am I losing too much efficiency by replacing a 'std::queue' with a 'std::deque'?

Thanks!
Dear hebrerillo

It seems that std::queue internally use std::deque as default, probably to realize queue concept.
Though I do not test, probably basic efficiency should be the same.

http://www.cplusplus.com/reference/queue/queue/

("Container" template parameter is set as deque)

Kind regards
Last edited on
Mitsuru is right. std::queue uses std::deque by default. The main reason to use std::queue is to get a cleaner queue interface with push/pop instead of push_back/pop_front.
Last edited on
Hi guys!

Yes you are right, I did not realize that the underlying container is actually an std::deque.

Thanks a lot!!
Topic archived. No new replies allowed.