- This wiki is out of date, use the continuation of this wiki instead
Quicksort
From FenixWiki
(Difference between revisions)
Revision as of 00:40, 12 July 2007 (edit) Sandman (Talk | contribs) m (→Parameters) ← Previous diff |
Revision as of 00:40, 12 July 2007 (edit) (undo) Sandman (Talk | contribs) m (→Parameters) Next diff → |
||
Line 13: | Line 13: | ||
| '''VOID POINTER''' array || - [[Pointer]] to the first element of the [[array]] to be sorted. | | '''VOID POINTER''' array || - [[Pointer]] to the first element of the [[array]] to be sorted. | ||
|- | |- | ||
- | | '''INT''' size || - The | + | | '''INT''' size || - The size of an element in the array in bytes. |
|- | |- | ||
| '''INT''' datacount || - The number of elements in the array. | | '''INT''' datacount || - The number of elements in the array. | ||
Line 19: | Line 19: | ||
| '''INT''' dataoffset || - The number of [[byte]]s the sort-[[variable]] in each element is relative to the start of that element. | | '''INT''' dataoffset || - The number of [[byte]]s the sort-[[variable]] in each element is relative to the start of that element. | ||
|- | |- | ||
- | | '''BYTE''' datasize || - The | + | | '''BYTE''' datasize || - The size of the sort-variable in bytes. |
|- | |- | ||
| '''BYTE''' type || - The type of the sort-variable. (0:[[int]]eger, 1:[[float]]) | | '''BYTE''' type || - The type of the sort-variable. (0:[[int]]eger, 1:[[float]]) |
Revision as of 00:40, 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