Mail Archives: djgpp/1997/03/12/11:24:19
>> Is there an algorithm available for a very fast sort?
>Look at the sources for the 'qsort()' function, which is
>part of djlsr201.zip which implements the Quick Sort
>algorithm.
>
As an alternative if you use C++ and you know about templates,
look at the header file <DJGPP>/lang/cxx/algo.h
This file is the STL implementation of many algorithms (including sort)
"... Importantly the resulting generic algorithms are efficient even
compared to hand crafted assembly code. For example the C++ standard
library algorithm 'sort()' is for many simple and realistic examples
several times faster than the C standard library 'qsort()' ..." [Stroustrup]
The STL function 'sort()' is faster since you can inline the comparison function
whereas in C 'qsort()' you must give the address of a real function.
Eyal.
- Raw text -