|
| |||||||||
| Tags: algorithm, cpp, functions, header files, library, stable_sort |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| What can be the use of the stable_sort() in the C++
Hello, I am the student of the MSC-CS. I could had the better knowledge of the C++ programming. I has also create the project that can be based on the inventory system in the C++ language. I can not have the much more knowledge about the functions of C++ programming language that can be in-built in the libraries. So, I would like to know about the stable_sort() function of the C++ language. I also would like to know about how can I use the stable_sort() function in the C++ programming language. Thus, Can anyone has the proper answer on the stable_sort() function in the C++ language. Reply Me!!! |
|
#2
| ||||
| ||||
| The use of the stable_sort()
Hello, The stable_sort() function can be used in the C++ language to Sort an elements that can be preserving or saving the order of an equivalents. The following can be the general syntax of the stable_sort(0 function in the C++ language as : Code: template <class RndmAcesItrtr> void stable_sort ( RndmAcesItrtr fst, RndmAcesItrtr lst );
__________________ Grand Theft Auto 4 PC Video Game |
|
#3
| ||||
| ||||
| The use of the stable_sort() in the C++
The following can be the parameters of the stable_sort() function in the C++ programming language : 1. comp : This parameter can be used in the stable_sort() function of the C++ language for an object of the Comparison function that can taking two values of the same type than those can be contained in the given specified range. 2. fst, lst : These parameters can be used in the stable_sort() function of the C++ language for Random-Access iterators to the final and starting positions of the sequence that can be stable_sorted. The range used can be [fst,lst).
__________________ The FIFA Manager 2009 PC Game |
|
#4
| ||||
| ||||
| What can be the use of the stable_sort() in the C++
The following program could illustrates you about that how you could use the stable_sort() function in the C++ language programming while using the stable_sort() function in the programming as shown below : Code: #include <iostream>
#include <algorithm>
#include <cassert>
using namespace std;
int main()
{
int c[1000];
int k;
for (k = 0; k < 1000; ++k)
c[k] = 1000 - k - 1;
stable_sort(&c[0], &c[1000]);
for (k = 0; k < 1000; ++k)
assert (c[k] == k);
return 0;
} |
|
#5
| ||||
| ||||
| Re: What can be the use of the stable_sort() in the C++ Program : Code: #include <iostream>
#include <algorchm>
#include <vector>
using namespace std;
bool mfnctn (int a,int b)
{
return (a<b);
}
struct myclass
{
bool operator() (int a,int b)
{
return (a<b);
}
}
mobjct;
int main ()
{
int mnt[] = {32,71,12,45,26,80,53,33};
vector<int> mctr (mnt, mnt+8);
vector<int>::cerator d;
stable_sort (mctr.begin(), mctr.begin()+4);
cout << "mctr contains:";
for (d=mctr.begin(); d!=mctr.end(); ++d)
cout << " " << *d;
cout << endl;
return 0;
} Code: mctr contains: 12 26 32 33 45 53 71 80 |
|
#6
| ||||
| ||||
| stable_sort() in the C++
The stable_sort() function algorithm of the C++ language can be similar to the sort() function algorithm. Unlike sort() function, Hence, stable_sort() function could preserved the actual ordering of an elements that can be equal to each other. This functionality can comes at a very small cost, hence, as stable_sort() function can takes a few more comparisons that can be sort() function in the worst case : M (log m)^2 in-spite of M log M. |