Search / Sort

This commit is contained in:
2026-08-30 22:24:45 +08:00
parent 3a4717a9d8
commit 0cb98557da
75 changed files with 7570 additions and 7 deletions
+68
View File
@@ -0,0 +1,68 @@
#ifndef INCLUDED_C_QUICKSORT_H
#define INCLUDED_C_QUICKSORT_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_QuickSort_Recursive(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_QuickSort_3Way(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_QuickSort_2Way_Optimized(void* base, c_size_t num, c_size_t size, c_SortCompare_t cmp, void* args);
/**
* @brief 工业级泛型自适应 Bentley-McIlroy 三路划分快速排序标准对外入口
*
* @param base 指向待排序连续数组首元素的指针
* @param num 数组中元素的总个数
* @param size 每个元素所占用的内存字节大小 (sizeof)
* @param cmp 带自定义上下文参数的比对回调函数指针 (不能为 NULL)
* @param args 传递给比对回调函数的自定义上下文参数指针
*/
void c_QuickSort_BentleyMcIlroy(void* base, c_size_t num, c_size_t size, c_SortCompare_t cmp, void* args);
/**
* @brief 工业级泛型非递归快速排序(显式模拟栈控制,彻底免疫 Stack Overflow
*
* @param base 指向待排序连续数组首元素的指针
* @param num 数组中元素的总个数
* @param size 每个元素所占用的内存字节大小 (sizeof)
* @param cmp 带自定义上下文参数的比对回调函数指针 (不能为 NULL)
* @param args 传递给比对回调函数的自定义上下文参数指针
*/
void c_QuickSort_Iterative(void* base, c_size_t num, c_size_t size, c_SortCompare_t cmp, void* args);
#endif /*INCLUDED_C_QUICKSORT_H*/