This commit is contained in:
Saturneic 2019-01-04 18:16:16 +08:00
parent 36560ef07b
commit 08f2d523c8
3 changed files with 138 additions and 26 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
/ZE-Standard-Libraries
/ZE-Standard-Libraries.sln
/.vs
*.xcodeproj

View File

@ -1,10 +1,19 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
//长链表模式可能启用则包含以下头文件
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
/**
@param p_list
@param target
@return
*/
Node *findByIntForNode(List *p_list, int target) {
Node *t_node;
int *p_target = (int *)malloc(sizeof(int));
@ -14,6 +23,13 @@ Node *findByIntForNode(List *p_list, int target) {
return t_node;
}
/**
@param p_list
@param target
@return
*/
Node *findByDoubleForNode(List *p_list, double target) {
Node *t_node;
double *p_target = (double *)malloc(sizeof(double));
@ -23,6 +39,13 @@ Node *findByDoubleForNode(List *p_list, double target) {
return t_node;
}
/**
@param p_list
@param target
@return
*/
Node *findByStringForNode(List *p_list, char *target) {
Node *t_node;
char *p_temp = (char *)malloc(sizeof(char)*(strlen(target) + 1));
@ -32,11 +55,27 @@ Node *findByStringForNode(List *p_list, char *target) {
return t_node;
}
/**
@param p_list
@param target
@return
*/
Node *findByPointerForNode(List *p_list, void *target) {
Node *t_node = findByValue(p_list, POINTER, target);
return t_node;
}
/**
@param p_list
@param temp
@return
*/
List *mply_findByInt(List* p_list, int temp) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
@ -49,6 +88,13 @@ List *mply_findByInt(List* p_list, int temp) {
return t_list;
}
/**
@param p_list
@param temp
@return
*/
List *mply_findByDouble(List* p_list, double temp) {
List *t_list;
double *p_temp = (double *)malloc(sizeof(double));
@ -61,6 +107,13 @@ List *mply_findByDouble(List* p_list, double temp) {
return t_list;
}
/**
@param p_list
@param temp
@return
*/
List *mply_findByString(List* p_list, char *temp) {
List *t_list;
char *p_temp = (char *)malloc(sizeof(char)*(strlen(temp) + 1));
@ -73,44 +126,75 @@ List *mply_findByString(List* p_list, char *temp) {
return t_list;
}
/**
@param p_list
@param temp
@return
*/
List *mply_findByPointer(List* p_list, void *temp) {
List *t_list = mply_findByValue(p_list, DOUBLE, (void *)temp);
return t_list;
}
List *mply_findByIntForNode(List* p_list, int temp) {
int *p_temp = (int *)malloc(sizeof(int));
if(p_temp == NULL){
return NULL;
}
*p_temp = temp;
return mply_findByValue(p_list, INT, (void *)p_temp);
/**
@param p_list
@param temp
@return
*/
inline List *mply_findByIntForNode(List* p_list, int temp) {
return mply_findByInt(p_list, temp);
}
List *mply_findByDoubleForNode(List* p_list, double temp) {
double *p_temp = (double *)malloc(sizeof(double));
if(p_temp == NULL){
return NULL;
}
*p_temp = temp;
return mply_findByValue(p_list, DOUBLE, (void *)p_temp);
/**
@param p_list
@param temp
@return
*/
inline List *mply_findByDoubleForNode(List* p_list, double temp) {
return mply_findByDouble(p_list, temp);
}
List *mply_findByStringForNode(List* p_list, char *temp) {
char *p_temp = (char *)malloc(sizeof(char) * (strlen(temp) + 1));
if(p_temp == NULL){
return NULL;
}
strcpy(p_temp, temp);
return mply_findByValue(p_list, STRING, (void *)p_temp);
/**
@param p_list
@param temp
@return
*/
inline List *mply_findByStringForNode(List* p_list, char *temp) {
return mply_findByString(p_list, temp);
}
List *mply_findByPointerForNode(List* p_list, void *temp) {
return mply_findByValue(p_list, POINTER, (void *)temp);
/**
@param p_list
@param temp
@return
*/
inline List *mply_findByPointerForNode(List* p_list, void *temp) {
return mply_findByPointer(p_list, temp);
}
/**
@param p_list
@param m_index
@return
*/
Node *findByIndexForNode(List *p_list, unsigned long long m_index) {
if(p_list == NULL) return NULL;
//当长链表模式可能启用时编译以下语句
#ifdef list_quick_enable
if(p_list->p_lq != NULL){
register struct list_quick *p_lq = p_list->p_lq;

View File

@ -1,27 +1,53 @@
#include <type.h>
#include <list/list.h>
#include <list/list_expand.h>
//长链表模式可能启用则包含以下头文件
#ifdef list_quick_enable
#include <list/list_quick.h>
#endif
/*直接获得节点中储存的字符串值*/
/**
@param p_node
@return
*/
char *getByStringForNode(Node *p_node) {
if (p_node->type == STRING) return (char *)(p_node->value);
else return NULL;
}
/**
@param p_node
@return
*/
double getByDoubleForNode(Node *p_node) {
if (p_node->type == DOUBLE) return *(double *)(p_node->value);
else return -1;
else return -1.0;
}
/**
@param p_node
@return
*/
void *getByPointerForNode(Node *p_node) {
return (void *)(p_node->value);
}
/**
@param p_list
@param p_node
@return 0
*/
unsigned long long getIndexByNode(List *p_list, Node *p_node) {
// 长链表模式可能启用则编译以下代码
#ifdef list_quick_enable
if (p_list->p_lq != NULL){
register Node **p_fn_node = p_list->p_lq->fn_node;
@ -32,6 +58,7 @@ unsigned long long getIndexByNode(List *p_list, Node *p_node) {
register Node *t_node = p_list->head;
register unsigned long long index = 0;
while (t_node != NULL) {
// id模块可能启用的时候则编译以下代码
#ifdef id_enable
if (p_node->s_id == t_node->s_id) return index;
#endif