diff options
Diffstat (limited to 'src/lib/libc/stdlib/radixsort.3')
-rw-r--r-- | src/lib/libc/stdlib/radixsort.3 | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/lib/libc/stdlib/radixsort.3 b/src/lib/libc/stdlib/radixsort.3 index a2af9f17a4..028837d4d1 100644 --- a/src/lib/libc/stdlib/radixsort.3 +++ b/src/lib/libc/stdlib/radixsort.3 | |||
@@ -9,11 +9,7 @@ | |||
9 | .\" 2. Redistributions in binary form must reproduce the above copyright | 9 | .\" 2. Redistributions in binary form must reproduce the above copyright |
10 | .\" notice, this list of conditions and the following disclaimer in the | 10 | .\" notice, this list of conditions and the following disclaimer in the |
11 | .\" documentation and/or other materials provided with the distribution. | 11 | .\" documentation and/or other materials provided with the distribution. |
12 | .\" 3. All advertising materials mentioning features or use of this software | 12 | .\" 3. Neither the name of the University nor the names of its contributors |
13 | .\" must display the following acknowledgement: | ||
14 | .\" This product includes software developed by the University of | ||
15 | .\" California, Berkeley and its contributors. | ||
16 | .\" 4. Neither the name of the University nor the names of its contributors | ||
17 | .\" may be used to endorse or promote products derived from this software | 13 | .\" may be used to endorse or promote products derived from this software |
18 | .\" without specific prior written permission. | 14 | .\" without specific prior written permission. |
19 | .\" | 15 | .\" |
@@ -29,32 +25,33 @@ | |||
29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
30 | .\" SUCH DAMAGE. | 26 | .\" SUCH DAMAGE. |
31 | .\" | 27 | .\" |
32 | .\" from: @(#)radixsort.3 8.2 (Berkeley) 1/27/94 | 28 | .\" $OpenBSD: radixsort.3,v 1.9 2003/06/02 20:18:38 millert Exp $ |
33 | .\" $Id: radixsort.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ | ||
34 | .\" | 29 | .\" |
35 | .Dd January 27, 1994 | 30 | .Dd January 27, 1994 |
36 | .Dt RADIXSORT 3 | 31 | .Dt RADIXSORT 3 |
37 | .Os | 32 | .Os |
38 | .Sh NAME | 33 | .Sh NAME |
39 | .Nm radixsort | 34 | .Nm radixsort , |
35 | .Nm sradixsort | ||
40 | .Nd radix sort | 36 | .Nd radix sort |
41 | .Sh SYNOPSIS | 37 | .Sh SYNOPSIS |
42 | .Fd #include <limits.h> | 38 | .Fd #include <limits.h> |
43 | .Fd #include <stdlib.h> | 39 | .Fd #include <stdlib.h> |
44 | .Ft int | 40 | .Ft int |
45 | .Fn radixsort "u_char **base" "int nmemb" "u_char *table" "u_int endbyte" | 41 | .Fn radixsort "const u_char **base" "int nmemb" "const u_char *table" "u_int endbyte" |
46 | .Ft int | 42 | .Ft int |
47 | .Fn sradixsort "u_char **base" "int nmemb" "u_char *table" "u_int endbyte" | 43 | .Fn sradixsort "const u_char **base" "int nmemb" "const u_char *table" "u_int endbyte" |
48 | .Sh DESCRIPTION | 44 | .Sh DESCRIPTION |
49 | The | 45 | The |
50 | .Fn radixsort | 46 | .Fn radixsort |
51 | and | 47 | and |
52 | .Fn sradixsort | 48 | .Fn sradixsort |
53 | functions | 49 | functions are implementations of radix sort. |
54 | are implementations of radix sort. | ||
55 | .Pp | 50 | .Pp |
56 | These functions sort an array of pointers to byte strings, the initial | 51 | These functions sort an array of |
57 | member of which is referenced by | 52 | .Fa nmemb |
53 | pointers to byte strings. | ||
54 | The initial member is referenced by | ||
58 | .Fa base . | 55 | .Fa base . |
59 | The byte strings may contain any values; the end of each string | 56 | The byte strings may contain any values; the end of each string |
60 | is denoted by the user-specified value | 57 | is denoted by the user-specified value |
@@ -63,26 +60,24 @@ is denoted by the user-specified value | |||
63 | Applications may specify a sort order by providing the | 60 | Applications may specify a sort order by providing the |
64 | .Fa table | 61 | .Fa table |
65 | argument. | 62 | argument. |
66 | If | 63 | If non-null, |
67 | .Pf non- Dv NULL , | ||
68 | .Fa table | 64 | .Fa table |
69 | must reference an array of | 65 | must reference an array of |
70 | .Dv UCHAR_MAX | 66 | .Dv UCHAR_MAX |
71 | + 1 bytes which contains the sort | 67 | + 1 bytes which contains the sort weight of each possible byte value. |
72 | weight of each possible byte value. | ||
73 | The end-of-string byte must have a sort weight of 0 or 255 | 68 | The end-of-string byte must have a sort weight of 0 or 255 |
74 | (for sorting in reverse order). | 69 | (for sorting in reverse order). |
75 | More than one byte may have the same sort weight. | 70 | More than one byte may have the same sort weight. |
76 | The | 71 | The |
77 | .Fa table | 72 | .Fa table |
78 | argument | 73 | argument is useful for applications which wish to sort different characters |
79 | is useful for applications which wish to sort different characters | ||
80 | equally, for example, providing a table with the same weights | 74 | equally, for example, providing a table with the same weights |
81 | for A-Z as for a-z will result in a case-insensitive sort. | 75 | for A-Z as for a-z will result in a case-insensitive sort. |
82 | If | 76 | If |
83 | .Fa table | 77 | .Fa table |
84 | is NULL, the contents of the array are sorted in ascending order | 78 | is |
85 | according to the | 79 | .Dv NULL , |
80 | the contents of the array are sorted in ascending order according to the | ||
86 | .Tn ASCII | 81 | .Tn ASCII |
87 | order of the byte strings they reference and | 82 | order of the byte strings they reference and |
88 | .Fa endbyte | 83 | .Fa endbyte |
@@ -90,7 +85,7 @@ has a sorting weight of 0. | |||
90 | .Pp | 85 | .Pp |
91 | The | 86 | The |
92 | .Fn sradixsort | 87 | .Fn sradixsort |
93 | function is stable, that is, if two elements compare as equal, their | 88 | function is stable; that is, if two elements compare as equal, their |
94 | order in the sorted array is unchanged. | 89 | order in the sorted array is unchanged. |
95 | The | 90 | The |
96 | .Fn sradixsort | 91 | .Fn sradixsort |
@@ -107,7 +102,7 @@ particular, see D.E. Knuth's Algorithm R and section 5.2.5, exercise 10. | |||
107 | They take linear time relative to the number of bytes in the strings. | 102 | They take linear time relative to the number of bytes in the strings. |
108 | .Sh RETURN VALUES | 103 | .Sh RETURN VALUES |
109 | Upon successful completion 0 is returned. | 104 | Upon successful completion 0 is returned. |
110 | Otherwise, \-1 is returned and the global variable | 105 | Otherwise, \-1 is returned and the global variable |
111 | .Va errno | 106 | .Va errno |
112 | is set to indicate the error. | 107 | is set to indicate the error. |
113 | .Sh ERRORS | 108 | .Sh ERRORS |
@@ -122,15 +117,13 @@ is not 0 or 255. | |||
122 | .Pp | 117 | .Pp |
123 | Additionally, the | 118 | Additionally, the |
124 | .Fn sradixsort | 119 | .Fn sradixsort |
125 | function | 120 | function may fail and set |
126 | may fail and set | ||
127 | .Va errno | 121 | .Va errno |
128 | for any of the errors specified for the library routine | 122 | for any of the errors specified for the library routine |
129 | .Xr malloc 3 . | 123 | .Xr malloc 3 . |
130 | .Sh SEE ALSO | 124 | .Sh SEE ALSO |
131 | .Xr sort 1 , | 125 | .Xr sort 1 , |
132 | .Xr qsort 3 | 126 | .Xr qsort 3 |
133 | .Pp | ||
134 | .Rs | 127 | .Rs |
135 | .%A Knuth, D.E. | 128 | .%A Knuth, D.E. |
136 | .%D 1968 | 129 | .%D 1968 |
@@ -158,4 +151,5 @@ for any of the errors specified for the library routine | |||
158 | .Sh HISTORY | 151 | .Sh HISTORY |
159 | The | 152 | The |
160 | .Fn radixsort | 153 | .Fn radixsort |
161 | function first appeared in 4.4BSD. | 154 | function first appeared in |
155 | .Bx 4.4 . | ||