I am referring you to a previous link that compares the performance of qsort vs stdsort.qsort와 std :: sort의 비교
큰 std::map
을 채우는 C 프로그램을 작성했으며 배열을 정렬하고 싶습니다. 현재 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));
}
}
qsort
함수 정확하게 배열을 정렬한다. 나는 qsort
와 std::sort
의 성능을 비교하고자 std::sort
는하지만 전화 std::sort
호출이 ‘sort(port_count_t [10], long unsigned int)’
에 컴파일 오류
에게 통화에 대해 일치 기능을 제공하지 않습니다와
qsort
의 성능을 비교하고자 연산. 어떻게해야합니까?
질문에 대한 답변을 생각한다면 해당 답변을 수락하십시오. –