Import Upstream version 20180207
[hcoop/debian/mlton.git] / lib / mlton / basic / quick-sort.sig
CommitLineData
7f918cf1
CE
1(* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8signature QUICK_SORT =
9 sig
10 (* The comparison function ('a * 'a -> bool) for should be the <= funtion,
11 * not just <.
12 * This is necessary to handle duplicate elements.
13 *)
14 (* sortArray mutates the array it is passed and returns the same array *)
15 val sortArray: 'a array * ('a * 'a -> bool) -> unit
16 val sortList: 'a list * ('a * 'a -> bool) -> 'a list
17 val sortVector: 'a vector * ('a * 'a -> bool) -> 'a vector
18 end
19
20functor TestQuickSort (S: QUICK_SORT): sig end =
21struct
22
23val _ = print "TestQuickSort\n"
24
25open S
26
27val _ =
28 List.foreach
29 ([Array.array (0, 0),
30 Array.tabulate (100, fn _ => Random.natLessThan 10000)],
31 fn a => ignore (sortArray (a, op <=)))
32
33end