Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / libm2 / ArraySort.def
1 DEFINITION MODULE ArraySort;
2 (* 
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 $
6
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
10   "memory" order.
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.
16 *)
17   FROM SYSTEM IMPORT ADDRESS;   (* no generics in Modula-2, sorry *)
18
19   TYPE  CompareResult = (less, equal, greater);
20         CompareProc = PROCEDURE(ADDRESS, ADDRESS): CompareResult;
21
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 *)
26 END ArraySort.