- This wiki is out of date, use the continuation of this wiki instead
Quicksort
From FenixWiki
(Difference between revisions)
Revision as of 00:06, 12 July 2007 (edit) Sandman (Talk | contribs) ← Previous diff |
Revision as of 00:11, 12 July 2007 (edit) (undo) Sandman (Talk | contribs) (→Definition) Next diff → |
||
Line 5: | Line 5: | ||
'''STRING''' quicksort ( <'''VOID POINTER''' array> , <'''INT''' size> , <'''INT''' datacount> , <'''INT''' dataoffset> , <'''BYTE''' datasize> , <'''BYTE''' type> ) | '''STRING''' quicksort ( <'''VOID POINTER''' array> , <'''INT''' size> , <'''INT''' datacount> , <'''INT''' dataoffset> , <'''BYTE''' datasize> , <'''BYTE''' type> ) | ||
- | + | Sorts an array by the Quicksort ordering algorithm. | |
This function is very handy for user defined types for elements in which a sort-variable is present. | This function is very handy for user defined types for elements in which a sort-variable is present. |
Revision as of 00:11, 12 July 2007
Contents |
Definition
STRING quicksort ( <VOID POINTER array> , <INT size> , <INT datacount> , <INT dataoffset> , <BYTE datasize> , <BYTE type> )
Sorts an array by the Quicksort ordering algorithm.
This function is very handy for user defined types for elements in which a sort-variable is present.
Parameters
VOID POINTER array | - Pointer to the first element of the array to be sorted. |
INT size | - The size of an element in the array in bytes. |
INT datacount | - The number of elements in the array. |
INT dataoffset | - The number of bytes the sort-variable in each element is relative to the start of that element. |
BYTE datasize | - The size of the sort-variable in bytes. |
BYTE type | - The type of the sort-variable. (0:integer, 1:float) |
Returns
INT: true
Example
Program sorting; Const myarray_length = 10; Global int myarray[myarray_length-1]; Begin // Insert random numbers for(x=0; x<myarray_length; x++) myarray[x] = rand(0,100); end // Show array say("--------------------"); for(x=0; x<myarray_length; x++) say(x + " - " + myarray[x]); end // Sort quicksort(&myarray[0],sizeof(int),myarray_length,0,sizeof(int),0); // Show array say("--------------------"); for(x=0; x<myarray_length; x++) say(x + " - " + myarray[x]); end // Wait until ESC is pressed Repeat frame; Until(key(_esc)) End