C++ Standard Library partial_sort_copy() Sample

Description

partial_sort_copy() produces a sorted sequence of N elements, copied to an output iterator. The input sequence is unmodified. This is useful, for example, in making a list of the highest values of a given sequence.

Declaration

	template <class In, class Ran>
	    Ran partial_sort_copy(In, In, Ran, Ran);
	template <class In, class Ran, class Cmp>
	    Ran partial_sort_copy(In, In, Ran, Ran, Cmp);

Concept

The program defines a vector of unsorted integers, and then creates a vector<int> structure containing the five largest of the values. The normal comparison sense is reversed via a user-supplied comparison function.

Supported
Supported
Supported