From 16b326b1779cf2079d2e04a34b793a18ac3bb744 Mon Sep 17 00:00:00 2001 From: Saturneic Date: Thu, 3 Jan 2019 16:42:03 +0800 Subject: [PATCH] Fixed. --- src/list/list_sort.c | 18 ++++++++++++++++++ test/test.c | 13 ------------- test/test.h | 5 +---- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/list/list_sort.c b/src/list/list_sort.c index 6d97acf..0adea99 100644 --- a/src/list/list_sort.c +++ b/src/list/list_sort.c @@ -11,6 +11,15 @@ *返回: 如果成功返回0,如果失败则返回-1.*/ static int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node)); +/** + 链表排序函数,该函数不直接对用户开放 + + @param p_list 指向需要操作的链表的指针 + @param begin 开始的节点的序号 + @param end 结束的节点的序号 + @param func 指向判断条件的函数的函数指针,接受两个指向相关节点的指针,比较他们的大小并返回正负值。 + @return 成功进行操作则返回0 + */ static int sortList(List *p_list, unsigned long long begin, unsigned long long end, int(*func)(Node *f_node, Node *s_node)){ unsigned long long target_index = begin; register Node *t_node = findByIndexForNode(p_list, target_index); @@ -41,6 +50,15 @@ static int sortList(List *p_list, unsigned long long begin, unsigned long long e return 0; } + + +/** + 向用户开放的链表排序函数 + + @param p_list 指向需要操作的链表 + @param func 指向判断条件的函数的函数指针,接受两个指向相关节点的指针,比较他们的大小并返回正负值。 + @return 成功进行操作则返回0 + */ int sortListForCustom(List *p_list, int(*func)(Node *f_node, Node *s_node)){ #ifdef list_quick_enable if(p_list->p_lq != NULL && !p_list->p_lq->if_sort) p_list->p_lq->if_sort = 1; diff --git a/test/test.c b/test/test.c index 65025bb..cacba84 100644 --- a/test/test.c +++ b/test/test.c @@ -47,19 +47,6 @@ int list(void) { return 0; }*/ -int stack(void) { - int i; - Stack *t_stack = initStack(); - for (i = 0; i < 10; i++) { - pushStack(t_stack, snodeWithInt(i)); - } - for (i = 0; i < 10; i++) { - printf("%d", getValueByIntForSNode(popStack(t_stack))); - } - releaseStack(t_stack); - return 0; -} - int time_avg(void){ List *t_list = initList(0); int64_t time_all = 0; diff --git a/test/test.h b/test/test.h index adb1ab8..7f9e36b 100644 --- a/test/test.h +++ b/test/test.h @@ -9,10 +9,7 @@ #include #include #include -#include -#include -//#include "tree/tree_expand.h" -#include "communicate/communicate.h" +#include int stack(void); int list(void);