delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/14/09:30:28

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Sorting?
Date: 14 Mar 1997 06:21:49 GMT
Organization: The National Capital FreeNet
Lines: 41
Message-ID: <5gaqpt$dbr@freenet-news.carleton.ca>
References: <2 DOT 2 DOT 32 DOT 19970312203832 DOT 00687230 AT mailhost>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet2.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Eyal Ben-David (eyalb AT aks DOT com) writes:
>>> 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)

Well, even were I to have an STL compiler for DJGPP (I only have gcc and
g++, not even gnu pascal or g77), I don't know the STL language, whatever
it is, and therefore could not translate STL code into C. (Plus
translating is a pain, learning a new language for a single freaking
function is a bigger pain, and there must be C++ implementations of sorts
somewhere that don't involve downloading the world's biggest zipfile!)

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

I need fast. I need to be able to sort several hundred polygons at least
30 times a second. On the other hand, I do not feel up to tackling STL so
soon after learning C++. (That was yesterday.) However, there is something
confusing here. There are three mentions of sort(), of which two state it
is STL and one C++. Which is it, or are you referring to an implementation
in each language, of which the C++ one I suppose is LGPL'ed?

--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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