Standard C++ Library Class Reference

Click on the banner to return to the Class Reference home page.
©Copyright 1996 Rogue Wave Software
partial_sort_copy
Algorithm
Summary
Templated algorithm for sorting collections of entities.
Contents
Synopsis
Description
Complexity
Example
Warning
See Also
Synopsis
#include <algorithm>
template <class InputIterator,
class RandomAccessIterator>
void partial_sort_copy (InputIterator first,
InputIterator last,
RandomAccessIterator result_first,
RandomAccessIterator result_last);
template <class InputIterator,
class RandomAccessIterator,
class Compare>
void partial_sort_copy (InputIterator first,
InputIterator last,
RandomAccessIterator result_first,
RandomAccessIterator result_last,
Compare comp);
Description
The partial_sort_copy algorithm places the smaller of last - first and result_last - result_first sorted elements from the range
[first, last) into the range beginning at result_first. (i.e., the range: [result_first, result_first+min(last - first, result_last -
result_first)). Basically, the effect is as if the range [first,last) were placed in a temporary buffer, sorted and then as many
elements as possible were coppied into the range [result_first, result_last).
The first version of the algorithm uses less than (operator<) as the comparison operator for the sort. The second version uses
the comparision function comp.