Container ?

M

Michael

Hi,

Could you please explain a little bit about the difference between the
following two groups.

group 1: std::vector std::deque std::list
group 2: std::stack std::queue std::priority_queue

I did not see much difference between group1 and group 2. When I just
need group 1? And, when I need group 1 and group 2?

Thanks,
Michael
 
V

Victor Bazarov

Michael said:
Could you please explain a little bit about the difference between the
following two groups.

group 1: std::vector std::deque std::list
group 2: std::stack std::queue std::priority_queue

I did not see much difference between group1 and group 2. When I just
need group 1? And, when I need group 1 and group 2?

Group 1 are containers. Group 2 are container adapters. Group 1 has
container traits: they store, contain, things. Group 2 are wrappers
over any of group 1, they represent a different interface for adding
and removing elements.

V
 
M

Michael

Victor said:
Group 1 are containers. Group 2 are container adapters. Group 1 has
container traits: they store, contain, things. Group 2 are wrappers
over any of group 1, they represent a different interface for adding
and removing elements.

Thanks for your quick reply. However, I think most of time I just need
container. I did not see what benefit I would get if I use container
adapter. Could you please give me an example?

Thanks a lot!
Michael
 
V

Victor Bazarov

Michael said:
Thanks for your quick reply. However, I think most of time I just need
container. I did not see what benefit I would get if I use container
adapter. Could you please give me an example?

If your algorithm calls for FIFO kind of processing of some objects, you
might want to use std::queue. If your algorithm operates in the FILO mode,
look at utilizing std::stack. But this is certainly true: if you have to
ask, you don't need those. When you have the need, you'll know. To find
an example, go to Google and search by the name of the adapter.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top