Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

sort

Name: Anonymous 2010-02-15 17:09

sort() can be compared to the qsort() function in the C standard library (in stdlib.h). sort is templated, so it uses the correct comparison function for whatever data type you are sorting, which is already implemented for standard data types. Otherwise you can specify your own comparison function, which can be type-checked by the compiler; whereas for qsort, you must manually cast pointers to the desired type in an unsafe way. Also, qsort accesses the comparison function using a function pointer, necessitating large numbers of repeated function calls, which can take a lot of time; whereas in C++, comparison functions are usually inlined, removing the need for function calls. In practice, C++ code using sort is often many times faster at sorting simple data like integers than equivalent C code using qsort.

Name: !iN.MY.aRMs 2010-02-16 1:17

take qsort.c replace data type with MACRO and get same speed as C++ anal shablons
or use FORTRAN77

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List