Fabricant : HP
Taille : 850.45 kb
Nom Fichier :
|
Par ce dispositif a également d'autres instructions :
Facilité d'utilisation
Complexity
partial_sort_copy does approximately (last-first) * log(min(last-first, result_last-result_first)) comparisons.
Example
//
// partsort.cpp
// #include
#include
#include
int main()
{
int d1[20] = {17, 3, 5, -4, 1, 12, -10, -1, 14, 7,
-6, 8, 15, -11, 2, -2, 18, 4, -3, 0};
//
// Set up a vector.
//
vector
//
// Output original vector.
//
cout << "For the vector: ";
copy(v1.begin(), v1.end(), ostream_iterator
//
// Partial sort the first seven elements.
//
partial_sort(v1.begin(), v1.begin()+7, v1.end());
//
// Output result.
//
cout << endl << endl << "A partial_sort of 7 elements gives: "
<< endl << " ";
copy(v1.begin(), v1.end(), ostream_iterator
cout << endl;
//
// A vector of ten elements.
//
vector
//
// Sort the last ten elements in v1 into v2.
//
partial_sort_copy(v1.begin()+10, v1.end(), v2.begin(),
v2.end());
//
// Output result.
//
cout << endl << "A partial_sort_copy of the last ten elements
gives: " << endl << " ";
copy(v2.begin(), v2.end(), ostream_iterator
cout << endl;
return 0;
}
Output :
For the vector: 17 3 5 -4 1 12 -10 -1 14 7 -6 8 15 -11 2 -2 18 4 -3 0
A partial_sort of seven elements gives:
-11 -10 -6 -4 -3 -2 -1 17 14 12 7 8 15 5 3 2 18 4 1 0
...
Ordinateurs - HP Integrity NonStop J-Series (850.45 kb)
Ordinateurs - HP NonStop G-Series (850.45 kb)
Ordinateurs - HP NonStop L-Series (850.45 kb)