Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-10-2008
Member
 
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.
Reply With Quote
  #2  
Old 25-10-2008
Member
 
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.
Reply With Quote
  #3  
Old 25-10-2008
Member
 
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.
Reply With Quote
  #4  
Old 25-10-2008
Member
 
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.
Reply With Quote
  #5  
Old 25-10-2008
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "STL container question"
Thread Thread Starter Forum Replies Last Post
.mov file container Rufta Windows Software 3 25-12-2010 03:27 PM
Need a .MOV File container VAIJAYI Windows Software 3 25-12-2010 04:08 AM
The list container of the C++ BossBattle Software Development 5 27-02-2010 08:39 PM
What is Servlet container? Sonam Goenka Software Development 5 05-02-2010 08:13 AM
How to create DB2 9.5 container Pollock Windows Software 3 12-08-2009 11:57 AM


All times are GMT +5.5. The time now is 12:58 AM.