src/core/sort_func.hpp
branchnoai
changeset 11126 72d4c9314c72
parent 11044 097ea3e7ec56
equal deleted inserted replaced
11111:1b984dab8cec 11126:72d4c9314c72
    18  * @param base Pointer to the first element of the array to be sorted.
    18  * @param base Pointer to the first element of the array to be sorted.
    19  * @param num Number of elements in the array pointed by base.
    19  * @param num Number of elements in the array pointed by base.
    20  * @param comparator Function that compares two elements.
    20  * @param comparator Function that compares two elements.
    21  * @param desc Sort descending.
    21  * @param desc Sort descending.
    22  */
    22  */
    23 template<typename T>
    23 template <typename T>
    24 FORCEINLINE void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
    24 static FORCEINLINE void QSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
    25 {
    25 {
    26 	if (num < 2) return;
    26 	if (num < 2) return;
    27 
    27 
    28 	qsort(base, num, sizeof(T), (int (CDECL *)(const void *, const void *))comparator);
    28 	qsort(base, num, sizeof(T), (int (CDECL *)(const void *, const void *))comparator);
    29 
    29 
    42  * @param base Pointer to the first element of the array to be sorted.
    42  * @param base Pointer to the first element of the array to be sorted.
    43  * @param num Number of elements in the array pointed by base.
    43  * @param num Number of elements in the array pointed by base.
    44  * @param comparator Function that compares two elements.
    44  * @param comparator Function that compares two elements.
    45  * @param desc Sort descending.
    45  * @param desc Sort descending.
    46  */
    46  */
    47 template<typename T>
    47 template <typename T>
    48 FORCEINLINE void GSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
    48 static inline void GSortT(T *base, uint num, int (CDECL *comparator)(const T*, const T*), bool desc = false)
    49 {
    49 {
    50 	if (num < 2) return;
    50 	if (num < 2) return;
    51 
    51 
    52 	assert(base != NULL);
    52 	assert(base != NULL);
    53 	assert(comparator != NULL);
    53 	assert(comparator != NULL);