This section is based on catpages contributed by Mainichi Communications, Inc. Translated by: MYCOM team Converted by: Japanese Online Manual Project <man-jp@jp.FreeBSD.ORG> Submitted by: Kazuo Horikawa <k-horik@yk.rim.or.jp>
149 lines
4.5 KiB
Groff
149 lines
4.5 KiB
Groff
.\" Copyright (c) 1990, 1991, 1993
|
||
.\" The Regents of the University of California. All rights reserved.
|
||
.\"
|
||
.\" Redistribution and use in source and binary forms, with or without
|
||
.\" modification, are permitted provided that the following conditions
|
||
.\" are met:
|
||
.\" 1. Redistributions of source code must retain the above copyright
|
||
.\" notice, this list of conditions and the following disclaimer.
|
||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||
.\" notice, this list of conditions and the following disclaimer in the
|
||
.\" documentation and/or other materials provided with the distribution.
|
||
.\" 3. All advertising materials mentioning features or use of this software
|
||
.\" must display the following acknowledgement:
|
||
.\" This product includes software developed by the University of
|
||
.\" California, Berkeley and its contributors.
|
||
.\" 4. Neither the name of the University nor the names of its contributors
|
||
.\" may be used to endorse or promote products derived from this software
|
||
.\" without specific prior written permission.
|
||
.\"
|
||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||
.\" SUCH DAMAGE.
|
||
.\"
|
||
.\" @(#)radixsort.3 8.2 (Berkeley) 1/27/94
|
||
.\"
|
||
.Dd January 27, 1994
|
||
.Dt RADIXSORT 3
|
||
.Os
|
||
.Sh ̾¾Î
|
||
.Nm radixsort
|
||
.Nd ´ð¿ô¥½¡¼¥È
|
||
.Sh ½ñ¼°
|
||
.Fd #include <limits.h>
|
||
.Fd #include <stdlib.h>
|
||
.Ft int
|
||
.Fn radixsort "const unsigned char **base" "int nmemb" "const unsigned char *table" "unsigned endbyte"
|
||
.Ft int
|
||
.Fn sradixsort "const unsigned char **base" "int nmemb" "const unsigned char *table" "unsigned endbyte"
|
||
.Sh ²òÀâ
|
||
.Fn radixsort
|
||
´Ø¿ô¤È
|
||
.Fn sradixsort
|
||
´Ø¿ô¤Ï¡¢´ð¿ô¥½¡¼¥È¤Î¥·¥¹¥Æ¥à¤Ç¤¹¡£
|
||
.Pp
|
||
¤³¤Î´Ø¿ô¤Ï¡¢
|
||
.Fa base
|
||
¤¬»²¾È¤¹¤ë½é´ü¥á¥ó¥Ð¤Ç¤¢¤ë¡¢¥Ð¥¤¥È¥¹¥È¥ê¥ó¥°¤Î¥Ý¥¤¥ó¥¿¤ÎÇÛÎó¤ò¥½¡¼¥È¤·
|
||
¤Þ¤¹¡£¥Ð¥¤¥È¥¹¥È¥ê¥ó¥°¤Ë¤ÏǤ°Õ¤ÎÃͤò´Þ¤á¤é¤ì¤Þ¤¹¡£³Æ¥¹¥È¥ê¥ó¥°¤ÎºÇ¸å¤Ë
|
||
¤Ï¡¢¥æ¡¼¥¶¤¬ÄêµÁ¤·¤¿ÃÍ
|
||
.Fa endbyte
|
||
¤¬ÉÕ¤¤Þ¤¹¡£
|
||
.Pp
|
||
¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¡¢
|
||
.Fa table
|
||
°ú¿ô¤ò»ØÄꤹ¤ë¤³¤È¤Ç¥½¡¼¥È½ç½ø¤ò»ØÄê¤Ç¤¤Þ¤¹¡£
|
||
.Dv NULL
|
||
¤Ç¤Ï¤Ê¤¤
|
||
.Fa table
|
||
¤Ï¡¢³Æ¥Ð¥¤¥ÈÃͤΥ½¡¼¥È¥¦¥§¥¤¥È¤ò´Þ¤à¡¢
|
||
.Dv UCHAR_MAX
|
||
+ 1 ¥Ð¥¤¥È¤ÎÇÛÎó¤ò»²¾È¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£ºÇ½ª¥¹¥È¥ê¥ó¥°¥Ð¥¤¥È¤Î¥½¡¼¥È
|
||
¥¦¥§¥¤¥È¤Ï¡¢0¤« 255(µÕ½ç¥½¡¼¥È)¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£Ê£¿ô¤Î¥Ð¥¤¥È¤Î¥½¡¼
|
||
¥È¥¦¥§¥¤¥È¤¬Åù¤·¤¤¤³¤È¤â¤¢¤ê¤Þ¤¹¡£
|
||
.Fa table
|
||
°ú¿ô¤Ï¡¢°Û¤Ê¤ë¥¥ã¥é¥¯¥¿¤òÅù¤·¤¯¥½¡¼¥È¤¹¤ë¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤ÇÊØÍø¤Ç¤¹¡£
|
||
¤¿¤È¤¨¤Ð A ¤«¤é Z ¤Î¥¦¥§¥¤¥È¤È a ¤«¤é z ¤Î¥¦¥§¥¤¥È¤òÅù¤·¤¯¤¹¤ë¤È¡¢Âçʸ
|
||
»ú¤È¾®Ê¸»ú¤Î¶èÊ̤ò¤·¤Ê¤¤¥½¡¼¥È¤¬¤Ç¤¤Þ¤¹¡£
|
||
.Fa table
|
||
¤¬ NULL ¤Ç¤¢¤ë¾ì¹ç¡¢ÇÛÎó¤ÎÆâÍÆ¤Ï¡¢»²¾È¤¹¤ë¥Ð¥¤¥È¥¹¥È¥ê¥ó¥°¤Î
|
||
.Tn ASCII
|
||
½ç½ø¤Ë½¾¤Ã¤Æ¾º½ç¤Ë¥½¡¼¥È¤µ¤ì¤Þ¤¹¡£
|
||
.Fa endbyte
|
||
¤Î¥½¡¼¥È¥¦¥§¥¤¥È¤Ï 0¤Ç¤¹¡£
|
||
.Pp
|
||
.Fn sradixsort
|
||
´Ø¿ô¤Ï°ÂÄꤷ¤Æ¤¤¤Þ¤¹¡£¤Ä¤Þ¤ê¡¢2¤Ä¤Î¥¨¥ì¥á¥ó¥È¤¬Åù¤·¤¤¾ì¹ç¡¢¤³¤Î¥¨¥ì¥á
|
||
¥ó¥È¤Î½ç½ø¤Ï¥½¡¼¥ÈºÑ¤ßÇÛÎó¤ÇÊѲ½¤·¤Þ¤»¤ó¡£
|
||
.Fn sradixsort
|
||
´Ø¿ô¤Ï¡¢
|
||
.Fa nmemb
|
||
¥Ý¥¤¥ó¥¿¤ò¼ýÍÆ¤¹¤ë¤Ë½½Ê¬¤Ê¥á¥â¥ê¤ò;ʬ¤Ë»ÈÍѤ·¤Þ¤¹¡£
|
||
.Pp
|
||
.Fn radixsort
|
||
´Ø¿ô¤ÏÉÔ°ÂÄê¤Ç¤¹¤¬¡¢¥á¥â¥ê¤ò;ʬ¤Ë»ÈÍѤ·¤Þ¤»¤ó¡£
|
||
.Pp
|
||
¤³¤Î´Ø¿ô¤Ï¡¢ºÇ¾å°Ì¥Ð¥¤¥È´ð¿ô¥½¡¼¥È¤Î¥Ð¥ê¥¨¡¼¥·¥ç¥ó¤Ç¤¹¡£D.E. Knuth ¤Î
|
||
¥¢¥ë¥´¥ê¥º¥à R ¤È¥»¥¯¥·¥ç¥ó 5.2.5¡¢¥¨¥¯¥µ¥µ¥¤¥º 10¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
|
||
¤³¤Î´Ø¿ô¤Ë¤Ï¡¢¥¹¥È¥ê¥ó¥°¤Î¥Ð¥¤¥È¿ô¤ËÈæÎ㤷¤¿»þ´Ö¤¬¤«¤«¤ê¤Þ¤¹¡£
|
||
.Sh Ìá¤êÃÍ
|
||
ÌäÂ꤬¤Ê¤¤¾ì¹ç¤Ï 0¤¬Ìᤵ¤ì¤Þ¤¹¡£ÌäÂ꤬¤¢¤ë¾ì¹ç¤Ï \-1¤¬Ìᤵ¤ì¡¢¥°¥í¡¼¥Ð
|
||
¥ëÊÑ¿ô
|
||
.Va errno
|
||
¤¬¡¢¤½¤Î¥¨¥é¡¼¤ò¼¨¤¹ÃͤËÀßÄꤵ¤ì¤Þ¤¹¡£
|
||
.Sh ¥¨¥é¡¼
|
||
.Bl -tag -width Er
|
||
.It Bq Er EINVAL
|
||
.Fa table
|
||
¤Î
|
||
.Fa endbyte
|
||
¥¨¥ì¥á¥ó¥È¤ÎÃͤ¬ 0¤« 255¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤»¤ó¡£
|
||
.El
|
||
.Pp
|
||
.Fn sradixsort
|
||
´Ø¿ô¤Ï¡¢¥¨¥é¡¼¤¬È¯À¸¤¹¤ë¤È¡¢¥é¥¤¥Ö¥é¥ê¥ë¡¼¥Á¥ó
|
||
.Xr malloc 3
|
||
¤Î¥¨¥é¡¼¤Ë
|
||
.Va errno
|
||
¤òÀßÄꤹ¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
|
||
.Sh ´ØÏ¢¹àÌÜ
|
||
.Xr sort 1 ,
|
||
.Xr qsort 3
|
||
.Pp
|
||
.Rs
|
||
.%A Knuth, D.E.
|
||
.%D 1968
|
||
.%B "The Art of Computer Programming"
|
||
.%T "Sorting and Searching"
|
||
.%V Vol. 3
|
||
.%P pp. 170-178
|
||
.Re
|
||
.Rs
|
||
.%A Paige, R.
|
||
.%D 1987
|
||
.%T "Three Partition Refinement Algorithms"
|
||
.%J "SIAM J. Comput."
|
||
.%V Vol. 16
|
||
.%N No. 6
|
||
.Re
|
||
.Rs
|
||
.%A McIlroy, P.
|
||
.%D 1993
|
||
.%B "Engineering Radix Sort"
|
||
.%T "Computing Systems"
|
||
.%V Vol. 6:1
|
||
.%P pp. 5-27
|
||
.Re
|
||
.Sh Îò»Ë
|
||
.Fn radixsort
|
||
´Ø¿ô¤Ï¡¢
|
||
.Bx 4.4
|
||
¤Ë½é¤á¤ÆÅо줷¤Þ¤·¤¿¡£
|