Container ?

Discussion in 'C++' started by Michael, Sep 7, 2006.

  1. Michael

    Michael Guest

    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
    Michael, Sep 7, 2006
    #1
    1. Advertising

  2. Michael wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Sep 7, 2006
    #2
    1. Advertising

  3. Michael

    Michael Guest

    Victor Bazarov wrote:

    >
    > 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
    Michael, Sep 7, 2006
    #3
  4. Michael wrote:
    > Victor Bazarov wrote:
    >
    >>
    >> 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?


    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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Sep 7, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vivi Orunitia
    Replies:
    11
    Views:
    4,444
    Martijn Lievaart
    Feb 4, 2004
  2. Maitre Bart
    Replies:
    2
    Views:
    507
    Maitre Bart
    Feb 11, 2004
  3. Steven T. Hatton
    Replies:
    4
    Views:
    3,861
    Rob Williscroft
    Dec 5, 2004
  4. Replies:
    4
    Views:
    776
    Daniel T.
    Feb 16, 2006
  5. wolverine
    Replies:
    2
    Views:
    434
    Marcus Kwok
    Jul 24, 2006
Loading...

Share This Page