Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7114
| From | Kai-Uwe Bux <jkherciueh@gmx.net> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Fast swapping of STL containers |
| Followup-To | comp.lang.c++ |
| Date | 2011-06-24 13:34 +0200 |
| Organization | University of Bielefeld |
| Message-ID | <iu1sne$roh$1@hoshi.visyn.net> (permalink) |
| References | <2879c8f0-969f-4ecb-8da8-86874b949168@t38g2000prj.googlegroups.com> <itvh7m$c95$1@dont-email.me> <bfadb469-e29c-45e1-aaf9-e6a9f056ad2f@28g2000pry.googlegroups.com> <67239772-4eef-4db5-be19-01a792194bb2@c41g2000yqm.googlegroups.com> <ff195525-e4c2-49dc-93b2-de59a4b83ad1@h12g2000pro.googlegroups.com> |
Followups directed to: comp.lang.c++
ittium wrote: > Thanks guys for your valuable time. I was actually thinking of writing > my own routines to solve this problem. > > I checked STL map documentation it actually contain swap routine. I > did some googling, I could not find any information regarding > performance of such an operation. > > From the discussion, it seems swap of standard container should be > fairly fast operation. > A standard link regarding this will help me convince other designers > in my group, to take this approach. Table 65 in the C++03 standard, last line: a.swap(b) is marked with (Note A) in the complexity column. That means: Those entries marked ``(Note A)'' should have constant complexity. BTW: a conforming implementation of the swap() method would have to be rather contrived to take more than constant time; after there is clause [23.1/10] which requires: a) the swap() method must not invalidate pointers, references, or iterators to elements of the containers being swapped. b) the swap() method must not throw unless the copy constructor or assignment operator of the _comparison_ objects might throw. That is, the copy constructor or assignment operator of the container elements might throw, but swap() is supposed to be unaffected by that. Best, Kai-Uwe Bux
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fast swapping of STL containers ittium <ittium@gmail.com> - 2011-06-23 06:45 -0700
Re: Fast swapping of STL containers Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-23 10:05 -0400
Re: Fast swapping of STL containers gwowen <gwowen@gmail.com> - 2011-06-23 08:07 -0700
Re: Fast swapping of STL containers Rune Allnor <allnor@tele.ntnu.no> - 2011-06-23 22:49 -0700
Re: Fast swapping of STL containers ittium <ittium@gmail.com> - 2011-06-24 02:16 -0700
Re: Fast swapping of STL containers Ian Collins <ian-news@hotmail.com> - 2011-06-24 21:27 +1200
Re: Fast swapping of STL containers ittium <ittium@gmail.com> - 2011-06-24 02:58 -0700
Re: Fast swapping of STL containers Ian Collins <ian-news@hotmail.com> - 2011-06-24 22:09 +1200
Re: Fast swapping of STL containers ittium <ittium@gmail.com> - 2011-06-24 03:29 -0700
Re: Fast swapping of STL containers Ian Collins <ian-news@hotmail.com> - 2011-06-24 22:44 +1200
Re: Fast swapping of STL containers Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-24 13:25 +0200
Re: Fast swapping of STL containers Ian Collins <ian-news@hotmail.com> - 2011-06-24 23:35 +1200
Re: Fast swapping of STL containers Pete Becker <pete@versatilecoding.com> - 2011-06-24 07:34 -0400
Re: Fast swapping of STL containers Kai-Uwe Bux <jkherciueh@gmx.net> - 2011-06-24 13:34 +0200
Re: Fast swapping of STL containers gwowen <gwowen@gmail.com> - 2011-06-24 03:26 -0700
Re: Fast swapping of STL containers ittium <ittium@gmail.com> - 2011-06-24 03:30 -0700
Re: Fast swapping of STL containers gwowen <gwowen@gmail.com> - 2011-06-24 04:01 -0700
Re: Fast swapping of STL containers Pete Becker <pete@versatilecoding.com> - 2011-06-24 07:37 -0400
Re: Fast swapping of STL containers gwowen <gwowen@gmail.com> - 2011-06-24 06:11 -0700
Re: Fast swapping of STL containers Werner <werasm@gmail.com> - 2011-06-24 02:29 -0700
Re: Fast swapping of STL containers Werner <werasm@gmail.com> - 2011-06-24 04:51 -0700
Re: Fast swapping of STL containers hanukas <jukka@liimatta.org> - 2011-06-29 05:29 -0700
Re: Fast swapping of STL containers Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-29 15:45 +0000
Re: Fast swapping of STL containers hanukas <jukka@liimatta.org> - 2011-06-30 23:46 -0700
csiph-web