使用例子:
int main()
{
deque<int>a;
INSERT_ELEMENTS(a, 3, 7);
INSERT_ELEMENTS(a, 2, 6);
INSERT_ELEMENTS(a, 1, 5);
PRINT_ELEMENTS(a);
partial_sort(a.begin(), a.begin() + 5, a.end());
PRINT_ELEMENTS(a);
partial_sort(a.begin(), a.begin() + 5, a.end(),greater<int>());
PRINT_ELEMENTS(a);
partial_sort(a.begin(), a.end(), a.end());
PRINT_ELEMENTS(a);
}
int main()
{
deque<int>a;
vector<int>b(6);
vector<int>c(30);
INSERT_ELEMENTS(a, 3, 7);
INSERT_ELEMENTS(a, 2, 6);
INSERT_ELEMENTS(a, 1, 5);
PRINT_ELEMENTS(a);
vector<int>::const_iterator bpos;
bpos = partial_sort_copy(a.cbegin(), a.cend(), b.begin(), b.end());
copy(b.cbegin(), bpos, ostream_iterator<int>(cout, " "));
cout << endl;
vector<int>::const_iterator cpos;
cpos = partial_sort_copy(a.cbegin(), a.cend(), c.begin(), c.end(),greater<int>());
copy(c.cbegin(), cpos, ostream_iterator<int>(cout, " "));
cout << endl;
}