Detailed Description
\c 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. Given an sequence containing: <pre> 0 1 2 3 4 5 6 7 8 9 </pre> a call to gather ( arr, arr + 10, arr + 4, IsEven ()) will result in: <pre> 1 3 0 2 4 6 8 5 7 9 |---|-----| first | second pivot </pre> The problem is broken down into two basic steps, namely, moving the items before the pivot and then moving the items from the pivot to the end. These "moves" are done with calls to stable_partition. \par Storage Requirements: The algorithm uses stable_partition, which will attempt to allocate temporary memory, but will work in-situ if there is none available. \par Time Complexity: If there is sufficient memory available, the run time is linear in <code>N</code>. If there is not any memory available, then the run time is <code>O(N log N)</code>. Function Documentation
iterator-based gather implementation Definition at line 78 of file gather.hpp.
range-based gather implementation Definition at line 100 of file gather.hpp. |