This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: performance analysis producer_consumer.cc TEST_T5


On Thu, Feb 19, 2004 at 06:14:45PM +0530, Dhruv Matani wrote:
> On Tue, 2004-02-17 at 22:29, Nathan Myers wrote:
> > On Tue, Feb 17, 2004 at 09:30:44AM -0700, law@redhat.com wrote:
> > 
> > std::list<>::size() is linear in N because the alternative would be
> > to make splicing linear.  The latter is the more commonly called in 
> > a loop.  (The splice operation on lists is among the most clever and
> > appealing features of the STL.  I claim credit for naming it.)
> > 
> > If you're very interested in the size of the container, you'll use 
> > a different data structure, or keep a separate count.  Note that 
> > maintaining a count is also linear in N, it's just that the cost is 
> > amortized over as many times as you look at it.
> 
> Why can't the library have a configure option to determine whether the
> size() function will be O(N) or not. It would be easy to provide both
> versions in the library AFAIK.

Because that would make the library worse, not better.  Configure
options are useful to tell configure things it can't figure out for 
itself, not to multiply the simultaneously released versions of the 
library and make code less portable among them.

Nathan Myers
ncm@cantrip.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]