home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
gnu
/
man
/
cat3
/
radixsort.0
< prev
next >
Wrap
Text File
|
1993-12-07
|
3KB
|
67 lines
RADIXSORT(3) UNIX Programmer's Manual RADIXSORT(3)
NNAAMMEE
rraaddiixxssoorrtt - radix sort
SSYYNNOOPPSSIISS
##iinncclluuddee <<lliimmiittss..hh>>
##iinncclluuddee <<ssttddlliibb..hh>>
_i_n_t
rraaddiixxssoorrtt(_u___c_h_a_r _*_*_b_a_s_e, _i_n_t _n_m_e_m_b, _u___c_h_a_r _*_t_a_b_l_e, _u___c_h_a_r _e_n_d_b_y_t_e)
DDEESSCCRRIIPPTTIIOONN
The rraaddiixxssoorrtt() function is a modified radix sort.
The rraaddiixxssoorrtt() function sorts an array of _n_m_e_m_b pointers to byte
strings, the initial member of which is referenced by _b_a_s_e. The byte
strings may contain any values; the end of each string is denoted by the
userspecified value _e_n_d_b_y_t_e. The contents of the array are sorted in as
cending order according to the ASCII order of the byte strings they ref
erence.
Applications may specify a sort order by providing the _t_a_b_l_e argument.
If nonNULL, _t_a_b_l_e must reference an array of UCHAR_MAX + 1 bytes which
contains the sort weight of each possible byte value. The endofstring
byte must have a sort weight of 0. More than one byte may have the same
sort weight. The _t_a_b_l_e argument is useful for applications which wish to
sort different characters equally; for example, providing a table with
the same weights for AZ as for az will result in a caseinsensitive
sort.
The rraaddiixxssoorrtt() function is stable, that is, if two elements compare as
equal, their order in the sorted array is unchanged.
The rraaddiixxssoorrtt() function is a variant of mostsignificantbyte radix
sorting; in particular, see D.E. Knuth's Algorithm R and section 5.2.5,
exercise 10. The rraaddiixxssoorrtt() function takes linear time relative to the
number of bytes in the strings.
RREETTUURRNN VVAALLUUEESS
Upon successful completion 0 is returned. Otherwise, -1 is returned and
the global variable _e_r_r_n_o is set to indicate the error.
EERRRROORRSS
The rraaddiixxssoorrtt() function may fail and set _e_r_r_n_o for any of the errors
specified for the library routine malloc(3).
SSEEEE AALLSSOO
sort(1), qsort(3)
Knuth, D.E., "Sorting and Searching", _T_h_e _A_r_t _o_f _C_o_m_p_u_t_e_r _P_r_o_g_r_a_m_m_i_n_g,
Vol. 3, pp. 170178, 1968.
Paige, R., "Three Partition Refinement Algorithms", _S_I_A_M _J_. _C_o_m_p_u_t_., No.
6, Vol. 16, 1987.
HHIISSTTOORRYY
The rraaddiixxssoorrtt() function is currently under development.
BBUUGGSS
The _n_m_e_m_b argument must be less than the maximum integer, INT_MAX.
BSD Experimental April 19, 1991 1