delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/12/11:24:19

Message-Id: <2.2.32.19970312203832.00687230@mailhost>
Mime-Version: 1.0
Date: Wed, 12 Mar 1997 18:38:32 -0200
To: djgpp AT delorie DOT com
From: Eyal Ben-David <eyalb AT aks DOT com>
Subject: Re: Sorting?

>> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019