Boost logo

Boost :

Subject: Re: [boost] Formal Review: Boost.RangeEx - missing algorithms
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-02-21 12:58:07


----- Original Message -----
From: "Thorsten Ottosen" <thorsten.ottosen_at_[hidden]>
To: <boost_at_[hidden]>; <boost-users_at_[hidden]>; <boost-announce_at_[hidden]>
Sent: Friday, February 20, 2009 10:03 AM
Subject: [boost] Formal Review: Boost.RangeEx

>
> Dear Developers and Users,
>
> It's my pleasure to announce that the review of Neil Groves' RangeEx
> library starts today and lasts until March 3, 2009.

Hi,

Excelent library Neil.

I was wondering if the following SGI algorithms should't be included in the library.

count_if
search_n
copy_n
fill_n
generate_n
remove_copy
remove_copy_if
unique_copy
reverse_copy
rotate_copy
random_shuffle
random_sample
random_sample_n
partial_sort_copy
is_sorted
is_heap

There are surely hidden reasons to don't include some of them.

I have a particular need, create a partition view of a range in n-sub-ranges

Currently I need to do for two partitions.

        boost::sub_range<Range> p0(boost::begin(range), boost::begin(range)+(size/2));
        boost::sub_range<Range> p1(boost::begin(range)+(size/2)+1, boost::end(range));

and for thre
        boost::sub_range<Range> p0(boost::begin(range), boost::begin(range)+(size/3));
        boost::sub_range<Range> p1(boost::begin(range)+(size/3)+1, boost::begin(range)+2*(size/3));
        boost::sub_range<Range> p2(boost::begin(range)+2*(size/3)+1, boost::end(range));

I have created a static partition class as follows:

template <typename Range, std::size_t Parts>
class partition
{
public:
    boost::array<boost::sub_range<Range>,Parts> parts;
    partition(boost::sub_range<Range>& range)
    {
        std::size_t size = boost::size(range);
        parts[0]=boost::sub_range<Range>(boost::begin(range), boost::begin(range)+(size/Parts));
        for (std::size_t i=1; i< Parts-1; ++i) {
            parts[i]=boost::sub_range<Range>(boost::begin(range)+i*(size/Parts)+1, boost::begin(range)+(i+1)*(size/Parts)+1);
        }
        parts[Parts-1]=boost::sub_range<Range>(boost::begin(range)+(Parts-1)*(size/Parts)+1, boost::end(range));
    }
};

But a dynamic one would also be interesting. What do you think?

Best,
Vicente


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