Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting a specific element from Queue

I have a queue:
queue<string> saves. I need to use it’s ability to remove elements from the front. Is there a way to get a specific element in the queue like the 5th one?
Neither saves.at(4) nor saves[4] works.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The entire point of a queue is you can only see and get the item, if any, waiting at the out end. Anything that allows you to see any other values in the queue is not a queue.

Wanting to see inside the queue suggests that you do not want a queue. Try a std::deque instead.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading