monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] using empty() instead of size()


From: Markus Wanner
Subject: Re: [Monotone-devel] using empty() instead of size()
Date: Mon, 22 Sep 2008 23:18:14 +0200
User-agent: Mozilla-Thunderbird 2.0.0.16 (X11/20080724)

Hi,

Zack Weinberg wrote:
I'm honestly surprised .empty() and .size() == 0 don't generate
identical code, but hey.  Thanks!

For example for doubly linked lists, it's pretty simple to tell whether they are empty or not, but counting the number of elements in the list requires traversing the list.

I'm not sure how other containers are affected. Plus some STL implementations might have optimizations for .size() to not require it to traverse the elements. However, its an optimization not required by the standard, AFAIK.

Regards

Markus





reply via email to

[Prev in Thread] Current Thread [Next in Thread]