Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] - Review by Neil Groves
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-10-18 11:10:13


On Oct 18, 2011, at 5:30 AM, Stewart, Robert wrote:

> Marshall Clow wrote:
>>
>> How about this:
>
> You can be more succinct:

I'm not really sure that being succinct is a goal.

>
>> [heading Complexity]
>>
>> All of the variants of `all_of` and `all_of_equal` run in
>> ['O(N)] (linear) time; that is, they compare against each
>> element in the list once. If any of the comparisons fail, the
>> algorithm will terminate immediately, without examining the
>> remaining members of the sequence.
>
> All variants of `all_of` and `all_of_equal` have ['O(N)] (linear) complexity. If an element fails the comparison, the algorithms return immediately. Otherwise, all elements in the input sequence are compared exactly once.

I like it!

>
>> [heading Exception Safety]
>>
>> All of the variants of `all_of` and `all_of_equal` take their
>> parameters by value or const reference, and do not depend upon
>> any global state. Therefore, all the routines in this file
>> provide the strong exception guarantee.
>
> All variants of `all_of` and `all_of_equal` provide the strong exception guarantee.

If I could explain why - instead of just asserting it - I think it would be better.
Dave has pointed out that my explanation here is incorrect.

>> [heading Notes]
>>
>> * `all_of` and `all_of_equal` both return true for empty
>> ranges, no matter what is passed to test against. When there
>> are no items in the sequence to test, they all satisfy the
>> condition to be tested against.
>
> [heading Empty Ranges]
>
> All variants of `all_of` and `all_of_equal` always return true for empty ranges.

This is a case where a bit of rationale adds to the explanation, I think.

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists_at_[hidden]>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk