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: Jens Finkhäuser
Subject: Re: [Monotone-devel] using empty() instead of size()
Date: Mon, 22 Sep 2008 22:21:38 +0100
User-agent: Mutt/1.5.17 (2007-11-01)

On Mon, Sep 22, 2008 at 02:14:25PM -0700, Zack Weinberg wrote:
> I'm honestly surprised .empty() and .size() == 0 don't generate
> identical code, but hey.  Thanks!
  Imagine a linked list implementation. Finding out whether the
pointer to the first element is NULL is simple, and enough to answer
whether the list is empty. Finding out the number of elements requires
traversing the list.

  Of course you can implement a linked list differently, but that'd be
how a very simple implementation might behave. At least some STL list
implementations behave in a similar fashion.

Jens




reply via email to

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