Boost logo

Boost :

Subject: Re: [boost] Painting a bikeshed ...
From: alex (alexhighviz_at_[hidden])
Date: 2015-10-03 09:50:43


> -----Original Message-----
> From: Boost [mailto:boost-bounces_at_[hidden]] On Behalf Of John
> Bytheway
> Sent: 03 October 2015 12:40
> To: boost_at_[hidden]
> Subject: Re: [boost] Painting a bikeshed ...
>
> On 2015-10-01 10:24, Marshall Clow wrote:
> > In Sean Parent's CppCon keynote last week, he went through the process
> > of implementing an algorithm he called "sort_subrange", which takes
> > four iterators describing two ranges, one a subset of the other, and
> > sorts the subrange - as if you had sorted the entire range. (See
> > https://www.youtube.com/watch?v=sWgDk-o-6ZE, starting at about 31:30).
> >
> > I have implemented this in Boost.Algorithm (crediting Sean) - called
> > partition_sort.
> >
> > However, while I was doing this, I thought of a different algorithm;
> > one that gathered all the elements into the subrange as if the entire
> > range was sorted, but didn't actually do the sorting.
> >

[...]

> and, having done that, I immediately feel like it ought to be variadic and
support
> arbitrarily many points to fix in sorted order
>
> void partition_subrange (
> Iterator first,
> Iterator... nth,
> Iterator last,
> Pred p)
>
> or even
>
> void partition_subrange (
> Iterator first,
> Range<Iterator> nth,
> Iterator last,
> Pred p)
>

+1

You can loosen the requirements by not requiring all of the partitions to be
subranges of a master range.

void partion_ranges(Ranges... r)

For instance three vectors {1, 4, 6} , {2, 5} and {3} could be partitioned
to {1, 3, 2} , {5, 4} and {6}.

Of course, the function does not need to have the word ranges in it.

void partion (Ranges... r)

And I still think stratify is more expressive...


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