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: Anonymous 2010-02-16 2:35

>>10
Heh. IIRC from my particle simulation days, Fortran77 is 72 columns, not 80. I learned the column limits the very hard way; it truncated a variable name in a math expression, and since you don't need to declare variables before using them, the truncated variable name was treated as a new variable with value zero. Spent fucking ages trying to figure out why my results were wrong.

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