On Thu, Mar 1, 2012 at 9:59 AM, Marco Morandini <morand...@aero.polimi.it>wrote:
> On 03/01/2012 04:51 PM, Andy Ray Terrel wrote: > >> On Thu, Mar 1, 2012 at 2:22 AM, Marco Morandini<morandini@aero.** >> polimi.it <morand...@aero.polimi.it>>wrote: >> >> There are some occurrences of >>> >>> container.size() == 0 >>> >>> scattered throughout the code >>> (and fewer of container.size() != 0) . >>> Many of them are harmless, i.e. whenever container >>> is a vector. Some of them, however, >>> are for maps of sets (e.g. dolfin/adaptivity/****Extrapolation.cpp:149 >>> ), >>> >>> leading to completely unnecessary O(N) operations (racall that size() is >>> O(N) for a map or a list). >>> >>> >>> While true for a list, it is not a problem for maps or sets: >> >> http://www.cplusplus.com/**reference/stl/map/size/<http://www.cplusplus.com/reference/stl/map/size/> >> http://www.cplusplus.com/**reference/stl/set/size/<http://www.cplusplus.com/reference/stl/set/size/> >> > > I stand corrected > > > While a silly implementation of a list will be O(n) most good >> implementations keep its size around. >> > > but please be aware that the "silly implementation" we are talking about > is gcc's one: > > http://gcc.gnu.org/onlinedocs/**libstdc++/manual/containers.** > html#sequences.list.size<http://gcc.gnu.org/onlinedocs/libstdc++/manual/containers.html#sequences.list.size> > > Marco > Yet another reason I hate gcc. Anywho the foo.empty() is better anyway as it does represent the idea. -- Andy
_______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : dolfin@lists.launchpad.net Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp