queue vs deque

Feb 20, 2019 at 7:30am
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!
Feb 20, 2019 at 7:42am
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 Feb 20, 2019 at 7:43am
Feb 20, 2019 at 8:28am
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 Feb 20, 2019 at 8:30am
Feb 20, 2019 at 9:55am
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.