Added sort functions for ADT Arrays, see sorting.inc
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401707
This commit is contained in:
@@ -45,6 +45,16 @@ enum SortOrder
|
||||
Sort_Descending = 1, /**< Descending order */
|
||||
};
|
||||
|
||||
/**
|
||||
* Data types for ADT Array Sorts
|
||||
*/
|
||||
enum SortType
|
||||
{
|
||||
Sort_Integer = 0,
|
||||
Sort_Float,
|
||||
Sort_String,
|
||||
};
|
||||
|
||||
/**
|
||||
* Sorts an array of integers.
|
||||
*
|
||||
@@ -128,3 +138,38 @@ funcenum SortFunc2D
|
||||
* @noreturn
|
||||
*/
|
||||
native SortCustom2D(array[][], array_size, SortFunc2D:sortfunc, Handle:hndl=INVALID_HANDLE);
|
||||
|
||||
/**
|
||||
* Sort an ADT Array. Specify the type as Integer, Float, or String.
|
||||
*
|
||||
* @param array Array Handle to sort
|
||||
* @param order Sort order to use, same as other sorts.
|
||||
* @param type Data type stored in the ADT Array
|
||||
* @noreturn
|
||||
*/
|
||||
native SortADTArray(Handle:array, SortOrder:order = Sort_Ascending, SortType:type = Sort_Integer);
|
||||
|
||||
/**
|
||||
* Sort comparison function for ADT Array elements. Function provides you with
|
||||
* indexes currently being sorted, use ADT Array functions to retrieve the
|
||||
* index values and compare.
|
||||
*
|
||||
* @param index1 First index to compare.
|
||||
* @param index2 Second index to compare.
|
||||
* @param array Array that is being sorted (order is undefined).
|
||||
* @param hndl Handle optionally passed in while sorting.
|
||||
* @return -1 if first should go before second
|
||||
* 0 if first is equal to second
|
||||
* 1 if first should go after second
|
||||
*/
|
||||
functag SortFuncADTArray public(index1, index2, Handle:array, Handle:hndl);
|
||||
|
||||
/**
|
||||
* Custom sorts an ADT Array. You must pass in a comparison function.
|
||||
*
|
||||
* @param array Array Handle to sort
|
||||
* @param sortfunc Sort comparision function to use
|
||||
* @param hndl Optional Handle to pass through the comparison calls.
|
||||
* @noreturn
|
||||
*/
|
||||
native SortADTArrayCustom(Handle:array, SortFuncADTArray:sortfunc, Handle:hndl=INVALID_HANDLE);
|
||||
Reference in New Issue
Block a user