Subject: Re: [boost] [EXTERNAL] New algorithm in Boost.Algorithm: "gather" -- looking for comments
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2013-01-23 09:46:53
On Jan 22, 2013, at 9:12 PM, "Belcourt, Kenneth" <kbelco_at_[hidden]> wrote:
> Hi Marshall,
> On Jan 21, 2013, at 5:49 PM, Marshall Clow wrote:
>> I have committed a new algorithm named "gather" into Boost.Algorithm.
> Are scatter and assemble algorithms also forthcoming?
I'm always open to suggestions.
>> gather() takes a collection of elements defined by a pair of iterators and moves the ones satisfying a predicate to them to a position (called the pivot) within the sequence. The algorithm is stable. The result is a pair of iterators that contains the items that satisfy the predicate.
> This is a good start, but I'd like to see gather generalized. One change is to lift the requirement for the pivot being internal to the element sequence as in many computational engineering applications we don't want to destroy the source elements when we perform the gather, we want to gather (some parts of) the elements into another buffer. In this mode, pivot becomes less apt as you're no longer pivoting in the source sequence. We'd also want to allow a different iterator type for the output buffer so perhaps something like:
>> template <typename ForwardIterator, typename OutputIterator, typename Pred>
>> gather ( ForwardIterator first, ForwardIterator last, OutputIterator result, Pred pred );
As Andrey said, I think you've just described copy_if.
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