]> git.saurik.com Git - apple/libc.git/blob - stdlib/FreeBSD/qsort.3.patch
Libc-498.tar.gz
[apple/libc.git] / stdlib / FreeBSD / qsort.3.patch
1 --- _SB/Libc/stdlib/FreeBSD/qsort.3 2004-11-25 11:38:42.000000000 -0800
2 +++ _SB/Libc/stdlib/FreeBSD/qsort.3.edit 2006-06-28 16:55:53.000000000 -0700
3 @@ -40,41 +40,44 @@
4 .Dt QSORT 3
5 .Os
6 .Sh NAME
7 -.Nm qsort , qsort_r , heapsort , mergesort
8 +.Nm heapsort ,
9 +.Nm mergesort ,
10 +.Nm qsort ,
11 +.Nm qsort_r
12 .Nd sort functions
13 .Sh LIBRARY
14 .Lb libc
15 .Sh SYNOPSIS
16 .In stdlib.h
17 +.Ft int
18 +.Fo heapsort
19 +.Fa "void *base"
20 +.Fa "size_t nel"
21 +.Fa "size_t width"
22 +.Fa "int \*[lp]*compar\*[rp]\*[lp]const void *, const void *\*[rp]"
23 +.Fc
24 +.Ft int
25 +.Fo mergesort
26 +.Fa "void *base"
27 +.Fa "size_t nel"
28 +.Fa "size_t width"
29 +.Fa "int \*[lp]*compar\*[rp]\*[lp]const void *, const void *\*[rp]"
30 +.Fc
31 .Ft void
32 .Fo qsort
33 .Fa "void *base"
34 -.Fa "size_t nmemb"
35 -.Fa "size_t size"
36 +.Fa "size_t nel"
37 +.Fa "size_t width"
38 .Fa "int \*[lp]*compar\*[rp]\*[lp]const void *, const void *\*[rp]"
39 .Fc
40 .Ft void
41 .Fo qsort_r
42 .Fa "void *base"
43 -.Fa "size_t nmemb"
44 -.Fa "size_t size"
45 +.Fa "size_t nel"
46 +.Fa "size_t width"
47 .Fa "void *thunk"
48 .Fa "int \*[lp]*compar\*[rp]\*[lp]void *, const void *, const void *\*[rp]"
49 .Fc
50 -.Ft int
51 -.Fo heapsort
52 -.Fa "void *base"
53 -.Fa "size_t nmemb"
54 -.Fa "size_t size"
55 -.Fa "int \*[lp]*compar\*[rp]\*[lp]const void *, const void *\*[rp]"
56 -.Fc
57 -.Ft int
58 -.Fo mergesort
59 -.Fa "void *base"
60 -.Fa "size_t nmemb"
61 -.Fa "size_t size"
62 -.Fa "int \*[lp]*compar\*[rp]\*[lp]const void *, const void *\*[rp]"
63 -.Fc
64 .Sh DESCRIPTION
65 The
66 .Fn qsort
67 @@ -84,7 +87,7 @@
68 function is a modified selection sort.
69 The
70 .Fn mergesort
71 -function is a modified merge sort with exponential search
72 +function is a modified merge sort with exponential search,
73 intended for sorting data with pre-existing order.
74 .Pp
75 The
76 @@ -92,18 +95,18 @@
77 and
78 .Fn heapsort
79 functions sort an array of
80 -.Fa nmemb
81 +.Fa nel
82 objects, the initial member of which is pointed to by
83 .Fa base .
84 The size of each object is specified by
85 -.Fa size .
86 +.Fa width .
87 The
88 .Fn mergesort
89 function
90 behaves similarly, but
91 .Em requires
92 that
93 -.Fa size
94 +.Fa width
95 be greater than
96 .Dq "sizeof(void *) / 2" .
97 .Pp
98 @@ -139,7 +142,7 @@
99 .Fn heapsort
100 are
101 .Em not
102 -stable, that is, if two members compare as equal, their order in
103 +stable; that is, if two members compare as equal, their order in
104 the sorted array is undefined.
105 The
106 .Fn mergesort
107 @@ -183,8 +186,8 @@
108 The function
109 .Fn mergesort
110 requires additional memory of size
111 -.Fa nmemb *
112 -.Fa size
113 +.Fa nel *
114 +.Fa width
115 bytes; it should be used only when space is not at a premium.
116 The
117 .Fn mergesort
118 @@ -195,8 +198,8 @@
119 Normally,
120 .Fn qsort
121 is faster than
122 -.Fn mergesort
123 -is faster than
124 +.Fn mergesort ,
125 +which is faster than
126 .Fn heapsort .
127 Memory availability and pre-existing order in the data can make this
128 untrue.
129 @@ -218,10 +221,10 @@
130 .Bl -tag -width Er
131 .It Bq Er EINVAL
132 The
133 -.Fa size
134 +.Fa width
135 argument is zero, or,
136 the
137 -.Fa size
138 +.Fa width
139 argument to
140 .Fn mergesort
141 is less than