Article View: comp.lang.modula2
Article #1885Generic sort p. 2
From: Ole Bjorn Tuftedal
Date: Thu, 04 Apr 1991 10:01
Date: Thu, 04 Apr 1991 10:01
48 lines
2463 bytes
2463 bytes
DEFINITION MODULE GenericSorting;
(* $SEG:=9; *)
(* Richard S. Wiener, SIGPLAN Notices, V19 #3, March 1984, pp 66-72. *)
(* Reference: Wiener, R.S., Sincovec, R.F., "Programming in Ada",
pp 294-297, John Wiley and Sons. *)
(*
Richard S. Wiener,
Department of Computer Science,
University of Colorado at Colorado Springs
Colorado Springs, Colorado 80907, U S A.
*)
(* Related modules: IMPLEMENTATION MODULE GenericSorting,
file name GENERICS.MOD
MODULE TstGenSorting;
file name TSTGENSO.MOD *)
FROM SYSTEM IMPORT WORD;
EXPORT QUALIFIED (* proc *) GenericSort;
TYPE UserProc = PROCEDURE(ARRAY OF WORD, ARRAY OF WORD): BOOLEAN;
(* The client program must supply a procedure that compares
two words of the type to be sorted. *)
PROCEDURE GenericSort(VAR ObjectArray: ARRAY OF WORD;
object1, object2: ARRAY OF WORD;
GreaterThan: UserProc); (* greater *)
(* GenericSort inputs an array of objects and returns the sorted
array of objects. The sorting is performed in-place, using
blocks of word, and the result is returned to the client program's
array of objects.
The first, reference, parameter is an array of objects.
The purpose of object1 and object2 is to provide workspace of the
correct word size.
The last parameter is a procedure parameter that enables a comparison
to be performed between two objects of the type being sorted.
The client program's object comparison procedure must exactly match
the specification given, i.e. it must have two ARRAY OF WORD parameters
and return a boolean result. *)
END GenericSorting.
Ole-Bjorn Tuftedal
University of Bergen, Norway
Internet: tuftedal@ifi.uib.no
Bitnet: sinot@nobergen
Technical Details
Message-ID:
<9104041001.AA17923@elg>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!att!ucbvax!IFI.UIB.NO!obShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!att!ucbvax!IFI.UIB.NO!ob From: ob@IFI.UIB.NO (Ole Bjorn Tuftedal) Newsgroups: comp.lang.modula2 Subject: Generic sort p. 2 Message-ID: <9104041001.AA17923@elg> Date: 4 Apr 91 10:01:18 GMT Article-I.D.: elg.9104041001.AA17923 Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@ucf1vm.cc.ucf.edu> Organization: The Internet Lines: 48