This commit is contained in:
Saturneic 2019-01-06 22:50:06 +08:00
parent 940087e820
commit 30323b5d63
5 changed files with 101 additions and 14 deletions

View File

@ -173,7 +173,7 @@ List *newCReturn(void);
/* /*
*,便 *,便
*/ */
unsigned long long getInfoForListThrough(List *expand_resources, int type); uint64_t getInfoForListThrough(List *expand_resources, int type);

View File

@ -5,8 +5,9 @@
/** /**
-1退1 -1退1
使
@param p_list @param p_list
@param p_func @param p_func
@return @return
@ -41,26 +42,34 @@ List *listThrough(List *p_list, List *(*p_func)(uint32_t, void *, List *), List
return m_rtnlst; return m_rtnlst;
} }
unsigned long long getInfoForListThrough(List *expand_resources, int type){
/**
type为1时用于回调函数获取当前参数列表的参数个数
type为2时用于获取当前节点在链表中的序号
@param expand_resources
@param type
@return
*/
uint64_t getInfoForListThrough(List *expand_resources, int type){
Node *p_node = NULL; Node *p_node = NULL;
if (type == 0) { if (type == 0) {
p_node = findByIndexForNode(expand_resources, expand_resources->length-1); p_node = findByIndexForNode(expand_resources, expand_resources->length-1);
}else{ }else{
p_node = findByIndexForNode(expand_resources, expand_resources->length-2); p_node = findByIndexForNode(expand_resources, expand_resources->length-2);
} }
return *((unsigned long long *)p_node->value); return *((uint64_t *)p_node->value);
} }
int getByIntForNode(Node *p_node) { /**
if (p_node->type == INT) return *(int *)(p_node->value);
else return -1;
}
unsigned int getByUIntForNode(Node *p_node){
if (p_node->type == UINT) return *(unsigned int *)(p_node->value);
else return -1;
}
@param if_status
@param status
@param argc
@param ...
@return
*/
List *newReturn(int if_status ,int status, char *argc, ...){ List *newReturn(int if_status ,int status, char *argc, ...){
List *p_list = initList(0); List *p_list = initList(0);
if(if_status){ if(if_status){
@ -116,6 +125,11 @@ List *newReturn(int if_status ,int status, char *argc, ...){
return p_list; return p_list;
} }
/**
@return
*/
List *newCReturn(void){ List *newCReturn(void){
return newReturn(1, 0, NULL); return newReturn(1, 0, NULL);
} }

View File

@ -6,6 +6,29 @@
#include <list/list_quick.h> #include <list/list_quick.h>
#endif #endif
/**
@param p_node
@return 0
*/
int getByIntForNode(Node *p_node) {
if (p_node->type == INT) return *(int *)(p_node->value);
else return 0;
}
/**
@param p_node
@return 0
*/
unsigned int getByUIntForNode(Node *p_node){
if (p_node->type == UINT) return *(unsigned int *)(p_node->value);
else return 0;
}
/** /**

View File

@ -4,7 +4,16 @@
#include <list/list_quick.h> #include <list/list_quick.h>
#endif #endif
/**
@param p_list
@param p_node
@return 0
*/
int insertInHead(List *p_list, Node *p_node) { int insertInHead(List *p_list, Node *p_node) {
// 如果可能需要使用长链表模块则编译以下代码
#ifdef list_quick_enable #ifdef list_quick_enable
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1; if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
if(p_list->p_lq != NULL){ if(p_list->p_lq != NULL){
@ -34,7 +43,15 @@ int insertInHead(List *p_list, Node *p_node) {
return 0; return 0;
} }
/**
@param p_list
@param p_node
@return 0
*/
int insertInTail(List *p_list, Node *p_node) { int insertInTail(List *p_list, Node *p_node) {
// 如果可能需要使用长链表模块则编译以下代码
#ifdef list_quick_enable #ifdef list_quick_enable
if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1; if(p_list->p_lq != NULL && p_list->p_lq->if_sort) return -1;
#endif #endif
@ -48,7 +65,7 @@ int insertInTail(List *p_list, Node *p_node) {
p_node->last = p_list->tail; p_node->last = p_list->tail;
p_list->tail = p_node; p_list->tail = p_node;
} }
// 如果可能需要使用长链表模块则编译以下代码
#ifdef list_quick_enable #ifdef list_quick_enable
if(p_list->p_lq != NULL){ if(p_list->p_lq != NULL){
p_node->f_number = p_list->p_lq->rlst_len; p_node->f_number = p_list->p_lq->rlst_len;

View File

@ -8,11 +8,18 @@
#include <id/id.h> #include <id/id.h>
#endif #endif
/**
@param p_list
@param priority
*/
void printListInfo(List *p_list, int priority) { void printListInfo(List *p_list, int priority) {
int i = 0; int i = 0;
Node *p_node; Node *p_node;
for (i = 0; i < priority; i++) printf(" "); for (i = 0; i < priority; i++) printf(" ");
printf("###LIST(location:%p",p_list); printf("###LIST(location:%p",p_list);
// 如果可能使用到ID模块则编译以下代码
#ifdef id_enable #ifdef id_enable
printf(",id:%s",s_idToASCIIString(p_list->s_id)); printf(",id:%s",s_idToASCIIString(p_list->s_id));
#endif #endif
@ -32,6 +39,12 @@ void printListInfo(List *p_list, int priority) {
} }
/**
@param p_list
*/
void printList(List *p_list) { void printList(List *p_list) {
int if_nearLast = 0; int if_nearLast = 0;
Node *p_node = p_list->head; Node *p_node = p_list->head;
@ -61,6 +74,13 @@ void printList(List *p_list) {
printf("]"); printf("]");
} }
/**
@param p_node
@param priority
*/
void printNodeInfo(Node *p_node, int priority) { void printNodeInfo(Node *p_node, int priority) {
int i; int i;
for (i = 0; i < priority; i++) printf(" "); for (i = 0; i < priority; i++) printf(" ");
@ -96,6 +116,11 @@ void printNodeInfo(Node *p_node, int priority) {
printf("}\n"); printf("}\n");
} }
/**
@param p_node
*/
void printNode(Node *p_node) { void printNode(Node *p_node) {
int i; int i;
printf("#NODE(location:%p",p_node); printf("#NODE(location:%p",p_node);
@ -132,6 +157,13 @@ void printNode(Node *p_node) {
printf("}\n"); printf("}\n");
} }
/**
@param p_list
@param func
*/
void printListForCustom(List *p_list,void (*func)(void *value)){ void printListForCustom(List *p_list,void (*func)(void *value)){
printf("###LIST (LEN:%llu ",p_list->length); printf("###LIST (LEN:%llu ",p_list->length);
#ifdef id_enable #ifdef id_enable
@ -141,6 +173,7 @@ void printListForCustom(List *p_list,void (*func)(void *value)){
listThrough(p_list, __CALLBACK_CALL(printListForCustom), __SEND_ARG("%p", func)); listThrough(p_list, __CALLBACK_CALL(printListForCustom), __SEND_ARG("%p", func));
} }
__CALLBACK_DEFINE(printListForCustom){ __CALLBACK_DEFINE(printListForCustom){
void (*func)(void *) = __ARGS_P(0, void); void (*func)(void *) = __ARGS_P(0, void);
printf("NODE (IDX:%llu ",__NOW_INDEX); printf("NODE (IDX:%llu ",__NOW_INDEX);