1 DEFINITION MODULE ArraySort;
3 Module: Array sorting module
4 Author: Ceriel J.H. Jacobs
5 Date: $Id: ArraySort.def,v 1.2 1994/06/24 12:48:16 ceriel Exp $
7 Interface is like the qsort() interface in C, so that an array of values
8 can be sorted. This does not mean that it has to be an ARRAY, but it does
9 mean that the values must be consecutive in memory, and the order is the
11 The user has to define a comparison procedure of type CompareProc.
12 This routine gets two pointers as parameters. These are pointers to the
13 opbjects that must be compared. The sorting takes place in ascending order,
14 so that f.i. if the result of the comparison is "less", the first argument
15 comes in front of the second.
17 FROM SYSTEM IMPORT ADDRESS; (* no generics in Modula-2, sorry *)
19 TYPE CompareResult = (less, equal, greater);
20 CompareProc = PROCEDURE(ADDRESS, ADDRESS): CompareResult;
22 PROCEDURE Sort(base: ADDRESS; (* address of array *)
23 nel: CARDINAL; (* number of elements in array *)
24 size: CARDINAL; (* size of each element *)
25 compar: CompareProc); (* the comparison procedure *)