Results 1 to 5 of 5

Thread: STL container question

  1. #1
    Join Date
    Oct 2008
    Posts
    55

    STL container question

    Hello

    I need to store a number of integer values which I will then search on
    later to see if they exist in my container. Can someone tell me which
    container would be quickest for finding these values? I can't use a
    plain C array (unless I make it 2^32 in size!) since I don't know the
    max integer value.

  2. #2
    Join Date
    Mar 2008
    Posts
    429

    Re: STL container question

    For that case, I think std::list is a better option, since the sorting will be faster
    Lists are implemented using pointers to point to the previous and to the next elements, so list::sort(), is more efficient by changing pointer values, while sorting a vector involves copying objects.

  3. #3
    Join Date
    Mar 2008
    Posts
    177

    Re: STL container question

    The original poster talked about storing integer values. I highly doubt sorting a list of integers will be faster than sorting an array of integers. In fact, I'm pretty sure of the contrary.

  4. #4
    Join Date
    Oct 2008
    Posts
    20

    Re: STL container question

    And you really think that doing two pointer exchanges is faster than one integer exchange?

    However, it can still be slower, since it's more or less the worst thing you
    can do to the cache.

  5. #5
    Join Date
    Sep 2008
    Posts
    7

    Re: STL container question

    Still, you should only get one cache-miss when looking for a value, if you use a set or vector you will probably get more.

Similar Threads

  1. .mov file container
    By Rufta in forum Windows Software
    Replies: 3
    Last Post: 25-12-2010, 03:27 PM
  2. Need a .MOV File container
    By VAIJAYI in forum Windows Software
    Replies: 3
    Last Post: 25-12-2010, 04:08 AM
  3. The list container of the C++
    By BossBattle in forum Software Development
    Replies: 5
    Last Post: 27-02-2010, 08:39 PM
  4. What is Servlet container?
    By Sonam Goenka in forum Software Development
    Replies: 5
    Last Post: 05-02-2010, 08:13 AM
  5. How to create DB2 9.5 container
    By Pollock in forum Windows Software
    Replies: 3
    Last Post: 12-08-2009, 11:57 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,580,023.69401 seconds with 17 queries