Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Where to use which STL container? Give short answer for each container, but that should suit the scenario.

+6 votes
asked May 8 by EklavyaDW (220 points)

2 Answers

0 votes
answered May 8 by Peter Minarik (72,620 points)

Depending on the definition, there could be up to 18 different STL containers.

You chose the right container based on the features of the container (e.g. is it static or dynamic? Is it ordered? How long does it take to find an element in it? How long does it take to insert an element in it? How long does it take to iterate through it; etc) to match the task at hand.

I think the documentation page linked above explains these features well. Now consider what your requirements are and chose accordingly.

If you're looking for a container for a specific task, let us know what task it is (detailed requirements) and we can help to choose. For academic purposes, refer to the linked manual.

0 votes
answered May 8 by Nick Nielsen (140 points)

Here is a good flow chart to help decide which one to use.

c++ - In which scenario do I use a particular STL container? - Stack  Overflow

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.