Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.x-privat.org!texta.sil.at!newsfeed01.chello.at!newsfeed02.chello.at!news.hispeed.ch.POSTED!not-for-mail Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Newsgroups: comp.lang.c++ Subject: Re: STL vector References: Date: Wed, 16 Nov 2011 08:58:04 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Peter Liedermann" Message-ID: User-Agent: Opera Mail/11.52 (Win32) X-Complaints-To: abuse@hispeed.ch Organization: hispeed.ch Lines: 35 NNTP-Posting-Host: 80.219.145.247 (80.219.145.247) NNTP-Posting-Date: Wed, 16 Nov 2011 09:00:07 +0100 X-Trace: 72f244ec36d87f57e345227557 Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:11504 On Wed, 16 Nov 2011 03:59:56 +0100, Joe Gottman wrote: > On 11/15/2011 2:50 PM, Peter Liedermann wrote: >> Hi there, >> >> Let "Jumbo" be the name of a class whose instances consume substantial >> storage. >> >> A vector of typically 1000 such Jumbo-instances is needed. It must be >> sorted by a simple int criterium, but not often. >> >> Is there a substantial performance difference between vector and >> vector , provided that everything else is adapted accordingly? >> Is there a difference at all? >> >> Thanx a lot, >> Peter >> > > 1) If you know in advance the size of the vector, you can reserve the > right amount of capacity before you start filling it and thus avoid the > costs of reallocation. yes, I do > > 2) If you can define an efficient swap() function for your class, > then sorting a vector would not involve any copying whatever. > I can certainly swap Jumbo * (pointers) easily, swapping Jumbo objects themselves is certainly (much?) more difficult. So I am determined to use Jumbo * as of now. Thanx for the clarification Peter