I am referring you to a previous link that compares the performance of qsort vs stdsort.
I have written a C program that populates a large std::map
and I want to sort the array.I am currently using qsort
.
typedef std::map<uint16_t, uint32_t> TSrcMap;
TPSrcMap sp;
TSrcMap::iterator its;
/*Code to populate the array_start.*/
/*Code to populate the array_end.*/
typedef struct port_count
{
uint32_t port_number;
uint32_t port_count;
}port_count_t;
port_count_t pcount[10];
memset(pcount,0,sizeof(pcount));
size_t structs_len = sizeof(pcount)/sizeof(port_count_t);
for(its = stcp.begin(); its != stcp.end();its++)
{
if(pcount[smallest_index].port_count < (*its).second)
{
pcount[smallest_index].port_count = (*its).second;
pcount[smallest_index].port_number = (*its).first;
/*qsort(pcount, structs_len, sizeof(port_count_t), struct_cmp_by_port_count);*/
std::sort(pcount,sizeof(port_count_t));
}
}
The qsort
function is correctly sorting the array. I want to compare the performance of qsort
with std::sort
but the call std::sort
call is giving a compile error
no matching function for call to
‘sort(port_count_t [10], long unsigned int)’
I would like to compare the performance of std::sort
with qsort
algorithm. How do I do that?