Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] is_ordered behaviour for singleton input, and name
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-09-23 12:39:15


On Sep 23, 2011, at 9:33 AM, Phil Endecott wrote:

> Dear All,
>
> The docs for the proposed is_ordered say:
>
> The function is_ordered(sequence, predicate) returns the point
> in the sequence where the predicate does not hold. It does that
> by comparing adjacent pairs of elements in the sequence to see if
> the predicate is satisfied. If all adjacent pairs satisfy the
> predicate, then it will return one past the last element of the
> sequence.
>
> OK.
>
> If the sequence has less than two elements, it returns
> the last element of the sequence. In other words, sequences of
> length zero and one are considered to be ordered - using any
> possible criteria.
>
> Shouldn't that say "it returns one past the last element"?

D'oh!
Yes, it should.

> Also, regarding the name: I would expect any "is_something" function to return a boolean. Since this returns an iterator I would have called it something like find_disorder. (There is a good chance that an iterator is convertible to bool, so one could mistakenly write "if (is_ordered(begin,end)) { ... }".)

"disorder" doesn't sit quite right with me for some reason.

How about "ordered_until", maybe?

or "find_unordered"

-- 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