Re: Challenge: fair partition function

2016-02-08 Thread Xinok via Digitalmars-d
On Monday, 8 February 2016 at 23:25:00 UTC, Andrei Alexandrescu wrote: Consider defining a function that partitions a range around a given index like this: size_t pivotPartition(alias less = (a, b) => a < b, Range) (Range r, size_t pivot); Returns x, one of the the indexes that r[pivot] would

Challenge: fair partition function

2016-02-08 Thread Andrei Alexandrescu via Digitalmars-d
Consider defining a function that partitions a range around a given index like this: size_t pivotPartition(alias less = (a, b) => a < b, Range) (Range r, size_t pivot); Returns x, one of the the indexes that r[pivot] would have if r were sorted. Also, r[0 .. x] contains stuff no greater than