Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: Fast swapping of STL containers Date: Fri, 24 Jun 2011 23:35:06 +1200 Lines: 35 Message-ID: <96jb3uFb9tU6@mid.individual.net> References: <2879c8f0-969f-4ecb-8da8-86874b949168@t38g2000prj.googlegroups.com> <67239772-4eef-4db5-be19-01a792194bb2@c41g2000yqm.googlegroups.com> <96j3l5Fb9tU1@mid.individual.net> <64e7c240-e321-4550-b65b-265f6950e2d3@x38g2000pri.googlegroups.com> <96j62qFb9tU3@mid.individual.net> <96j85mFb9tU5@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net iNPF2imuWHduBC/FARYECga6dvq6iBWh0KxqA5DQA22DvAAiL5 Cancel-Lock: sha1:uVX+8f/zI8feTnuWpEa/RLnOvK0= User-Agent: Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.c++:7116 On 06/24/11 11:25 PM, Kai-Uwe Bux wrote: > Ian Collins wrote: > >> On 06/24/11 10:29 PM, ittium wrote: >> >> Please stop snipping attributions, it's rude! >> >>>> What difference does the number of calls make? The operation is either >>>> efficient, or it isn't. >>>> >>> thanks Ian for quick response. >>> If operation is called limited number of times (e.g. only during >>> initialization of a process) you can live with it. But if it is called >>> large number of times and fast response time is required, complexity >>> is an important criteria before using a routine. >> >> How is the library designer to no how often a routine will be called? >> They will strive to get the best performance and that will be much >> better than a user will ever get! > > > Lessons: (a) sometimes and with some effort, the library designer can not > only measure how many times the routine will be called but also get an idea > of the typical arguments; (b) if your particular use case differs from the > case for which the library was optimized, you can sometimes rather easily > beat the library implementation. But not in the cast of an operation such as a container swap which can typically be implemented by exchanging some pointers to the internal data structure and a few other internal variables. The user would have to perform a copy and erase. -- Ian Collins