Boost logo

Boost :

Subject: Re: [boost] Review Request: Creasing (Sequence Properties)
From: Eric MALENFANT (Eric.Malenfant_at_[hidden])
Date: 2010-01-27 10:13:48


Joachim Faulhaber wrote:
> Hi Grant,
>
> 2010/1/24 Grant Erickson <gerickson_at_[hidden]>:
>> The creasing algorithm templates define four template functions for
>> determining the order properties of sequences, specifically:
>>
>>    * Increasing
>>    * Decreasing
>>    * Strictly Increasing
>>    * Strictly Decreasing
>
>
> in your implementation of 'creasing' you provide the four specific
> algorithms is_[strictly_]{in_,de_}creasing while hiding the general
> algorithm is_creasing in namespace detail.
>
> I'd suggest to implement only the latter. This would make your
> extension both more minimal and more general.
>
> template <typename ForwardIterator, typename BinaryPredicate>
> bool is_ordered(ForwardIterator first, ForwardIterator last,
> BinaryPredicate binary_pred)
> {
> return std::adjacent_find(first, last,
> std::not2(binary_pred)) == last;
> }
>

This looks a lot like the is_sorted algorithm from n3000:

    template<class ForwardIterator, class Compare>
    bool is_sorted(ForwardIterator first, ForwardIterator last,
                   Compare comp);

which also includes is_sorted_until:

    template<class ForwardIterator, class Compare>
    ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last,
                                    Compare comp);


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