Search / Sort
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
#ifndef INCLUDED_C_MERGESORT_H
|
||||
#define INCLUDED_C_MERGESORT_H
|
||||
|
||||
#ifndef INCLUDED_C_SORTCOMPARE_H
|
||||
#include <c_SortCompare.h>
|
||||
#endif /*INCLUDED_C_SORTCOMPARE_H*/
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
|
||||
/**
|
||||
* @brief 工业级泛型自顶向下归并排序入口
|
||||
*
|
||||
* @param base 指向待排序连续数组首元素的指针
|
||||
* @param num 数组中元素的总个数
|
||||
* @param size 每个元素所占用的内存字节大小 (sizeof)
|
||||
* @param cmp 带自定义上下文参数的比对回调函数指针 (不能为 NULL)
|
||||
* @param args 传递给比对回调函数的自定义上下文参数指针
|
||||
*/
|
||||
void c_MergeSort(void* base, c_size_t num, c_size_t size, c_SortCompare_t cmp, void* args);
|
||||
|
||||
/**
|
||||
* @brief 工业级泛型自底向上归并排序(纯迭代非递归,完全规避栈溢出风险)
|
||||
*
|
||||
* @param base 指向待排序连续数组首元素的指针
|
||||
* @param num 数组中元素的总个数
|
||||
* @param size 每个元素所占用的内存字节大小 (sizeof)
|
||||
* @param cmp 带自定义上下文参数的比对回调函数指针 (不能为 NULL)
|
||||
* @param args 传递给比对回调函数的自定义上下文参数指针
|
||||
*/
|
||||
void c_MergeSort_BottomUp(void* base, c_size_t num, c_size_t size, c_SortCompare_t cmp, void* args);
|
||||
|
||||
/**
|
||||
* @brief 工业级泛型优化版归并排序(哨兵阻断、小数组截断、零往返拷贝)
|
||||
*
|
||||
* @param base 指向待排序连续数组首元素的指针
|
||||
* @param num 数组中元素的总个数
|
||||
* @param size 每个元素所占用的内存字节大小 (sizeof)
|
||||
* @param cmp 带自定义上下文参数的比对回调函数指针 (不能为 NULL)
|
||||
* @param args 传递给比对回调函数的自定义上下文参数指针
|
||||
*/
|
||||
void c_MergeSort_Optimized(void* base, c_size_t num, c_size_t size, c_SortCompare_t cmp, void* args);
|
||||
|
||||
|
||||
#endif /*INCLUDED_C_MERGESORT_H*/
|
||||
Reference in New Issue
Block a user