Article View: comp.lang.modula2
Article #248Re: Sorts
From: Greg Granger
Date: Tue, 12 Sep 1989 15:38
Date: Tue, 12 Sep 1989 15:38
38 lines
2360 bytes
2360 bytes
AB>From: Alex Bewley <BOTCHAIR@UOGUELPH>
AB>Bubble sort is a little bit too slow for my application. I need to
AB>...
AB>pointers become mixed up and you end up trying to sort the interrupt
AB>...
AB>which I don't want to do.
Well, I was having the same problem a few months back. I was using
TopSpeed Modula-2 to read a directory (queue the filenames of a dir.)
and wanted to sort the results. TopSpeed provides a very useful
QuickSort and HeapSort with their 'standard' libraries, but these
routines quite reasonably expected a indexed list. (Note that the
TopSpeed canned sorts require as arguments the list size, a Less than
procedure and a Swap procedure, therefore the use of ARRAYs is not
mandated, this is not true with all such canned sorts)
In any case, what I did was write a module that allowed GETs, PUTs
and SWAPs on a heap based indexed list. This allows dynamic array
handling, which solved my problem. I have been reworking this module
lately to include, unlike types (not `true' arrays), dropping
elements, deinit'ing (kill the array and recovering all heap space
used), etc... I would be happy to share my source code with you
with the following understanding:
(A) this is a module being actively tested (deinit'ing is at this
time not functional)
(B) it's written in TopSpeed Modula-2 with absolutely no attention
given to keeping with the Wirth defined standard (ie if TS gave
me a special non-standard function that made things easier I
used it).
(C) Please don't pass the source code around, while I believe that
it will help you, it is not finished to the point that I would
like to have it floating around with my name on it.
-----
To interested other readers.
If other are interested in this code, let me know and I will
consider releasing it to the list when I have finished testing
and debugging.
Greg (GRANGERG @ VTVM1)
Technical Details
Message-ID:
<INFO-M2%89091211494450@UCF1VM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!VTVM1.BITNET!GRANGERGReferences:
<BOTCHAIR@UOGUELPH>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!ucbvax!VTVM1.BITNET!GRANGERG From: GRANGERG@VTVM1.BITNET (Greg Granger) Newsgroups: comp.lang.modula2 Subject: Re: Sorts Message-ID: <INFO-M2%89091211494450@UCF1VM> Date: 12 Sep 89 15:38:35 GMT References: <BOTCHAIR@UOGUELPH> Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> Organization: The Internet Lines: 38