Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #11504
| Newsgroups | comp.lang.c++ |
|---|---|
| Subject | Re: STL vector |
| References | <op.v4z6q8m5vc68pg@hp2011.workgroup> <KGFwq.32258$zC6.5650@en-nntp-15.dc1.easynews.com> |
| Date | 2011-11-16 08:58 +0100 |
| From | "Peter Liedermann" <peter09876@hispeed.ch> |
| Message-ID | <op.v404e2clvc68pg@hp2011.workgroup> (permalink) |
| Organization | hispeed.ch |
On Wed, 16 Nov 2011 03:59:56 +0100, Joe Gottman <josephgottman@comcast.net> 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 <Jumbo> and >> vector <Jumbo *>, 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<Jumbo> 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
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
STL vector "Peter Liedermann" <peter09876@hispeed.ch> - 2011-11-15 20:50 +0100
Re: STL vector Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-11-15 21:30 +0100
Re: STL vector Leigh Johnston <leigh@i42.co.uk> - 2011-11-15 21:13 +0000
Re: STL vector Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-11-15 22:46 +0100
Re: STL vector Leigh Johnston <leigh@i42.co.uk> - 2011-11-15 22:02 +0000
Re: STL vector / Heap fragmentation "Peter Liedermann" <peter09876@hispeed.ch> - 2011-11-16 09:02 +0100
Re: STL vector / Heap fragmentation Goran <goran.pusic@gmail.com> - 2011-11-16 00:39 -0800
Re: STL vector / Heap fragmentation "Peter Liedermann" <peter09876@hispeed.ch> - 2011-11-16 10:58 +0100
Re: STL vector / Heap fragmentation Goran <goran.pusic@gmail.com> - 2011-11-16 04:12 -0800
Re: STL vector "Peter Liedermann" <peter09876@hispeed.ch> - 2011-11-16 08:55 +0100
Re: STL vector yatremblay@bel1lin202.(none) (Yannick Tremblay) - 2011-11-16 16:54 +0000
Re: STL vector Joe Gottman <josephgottman@comcast.net> - 2011-11-16 18:22 -0500
Re: STL vector Joe Gottman <josephgottman@comcast.net> - 2011-11-15 21:59 -0500
Re: STL vector "Peter Liedermann" <peter09876@hispeed.ch> - 2011-11-16 08:58 +0100
Re: STL vector Werner <werasm@gmail.com> - 2011-11-16 05:53 -0800
Re: STL vector Leigh Johnston <leigh@i42.co.uk> - 2011-11-16 14:02 +0000
Re: STL vector Leigh Johnston <leigh@i42.co.uk> - 2011-11-16 14:05 +0000
Re: STL vector "Peter Liedermann" <peter09876@hispeed.ch> - 2011-11-17 16:45 +0100
Re: STL vector Leigh Johnston <leigh@i42.co.uk> - 2011-11-17 16:19 +0000
Re: STL vector Joshua Maurice <joshuamaurice@gmail.com> - 2011-11-17 15:19 -0800
csiph-web