Added.
This commit is contained in:
parent
36560ef07b
commit
08f2d523c8
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
|||||||
/ZE-Standard-Libraries
|
/ZE-Standard-Libraries
|
||||||
/ZE-Standard-Libraries.sln
|
/ZE-Standard-Libraries.sln
|
||||||
/.vs
|
/.vs
|
||||||
|
*.xcodeproj
|
||||||
|
@ -1,10 +1,19 @@
|
|||||||
#include <type.h>
|
#include <type.h>
|
||||||
#include <list/list.h>
|
#include <list/list.h>
|
||||||
#include <list/list_expand.h>
|
#include <list/list_expand.h>
|
||||||
|
//长链表模式可能启用则包含以下头文件
|
||||||
#ifdef list_quick_enable
|
#ifdef list_quick_enable
|
||||||
#include <list/list_quick.h>
|
#include <list/list_quick.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的整型值来找到链表中第一个符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param target 目标节点中储存的整型值
|
||||||
|
@return 返回指向目标节点的指针
|
||||||
|
*/
|
||||||
Node *findByIntForNode(List *p_list, int target) {
|
Node *findByIntForNode(List *p_list, int target) {
|
||||||
Node *t_node;
|
Node *t_node;
|
||||||
int *p_target = (int *)malloc(sizeof(int));
|
int *p_target = (int *)malloc(sizeof(int));
|
||||||
@ -14,6 +23,13 @@ Node *findByIntForNode(List *p_list, int target) {
|
|||||||
return t_node;
|
return t_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的双精度浮点值来找到链表中第一个符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param target 目标节点中储存的双精度浮点值
|
||||||
|
@return 返回指向目标节点的指针
|
||||||
|
*/
|
||||||
Node *findByDoubleForNode(List *p_list, double target) {
|
Node *findByDoubleForNode(List *p_list, double target) {
|
||||||
Node *t_node;
|
Node *t_node;
|
||||||
double *p_target = (double *)malloc(sizeof(double));
|
double *p_target = (double *)malloc(sizeof(double));
|
||||||
@ -23,6 +39,13 @@ Node *findByDoubleForNode(List *p_list, double target) {
|
|||||||
return t_node;
|
return t_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的字符串值来找到链表中第一个符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param target 目标节点中储存的字符数组值
|
||||||
|
@return 返回指向目标节点的指针
|
||||||
|
*/
|
||||||
Node *findByStringForNode(List *p_list, char *target) {
|
Node *findByStringForNode(List *p_list, char *target) {
|
||||||
Node *t_node;
|
Node *t_node;
|
||||||
char *p_temp = (char *)malloc(sizeof(char)*(strlen(target) + 1));
|
char *p_temp = (char *)malloc(sizeof(char)*(strlen(target) + 1));
|
||||||
@ -32,11 +55,27 @@ Node *findByStringForNode(List *p_list, char *target) {
|
|||||||
return t_node;
|
return t_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的指针值来找到链表中第一个符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param target 目标节点中储存的字符指针值
|
||||||
|
@return 返回指向目标节点的指针
|
||||||
|
*/
|
||||||
Node *findByPointerForNode(List *p_list, void *target) {
|
Node *findByPointerForNode(List *p_list, void *target) {
|
||||||
Node *t_node = findByValue(p_list, POINTER, target);
|
Node *t_node = findByValue(p_list, POINTER, target);
|
||||||
return t_node;
|
return t_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的整型值来找到链表中所有符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param temp 目标节点中储存的整型值
|
||||||
|
@return 返回包含所有符合条件的节点的新的重组链表
|
||||||
|
*/
|
||||||
List *mply_findByInt(List* p_list, int temp) {
|
List *mply_findByInt(List* p_list, int temp) {
|
||||||
int *p_temp = (int *)malloc(sizeof(int));
|
int *p_temp = (int *)malloc(sizeof(int));
|
||||||
if(p_temp == NULL){
|
if(p_temp == NULL){
|
||||||
@ -49,6 +88,13 @@ List *mply_findByInt(List* p_list, int temp) {
|
|||||||
return t_list;
|
return t_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的双精度浮点值来找到链表中所有符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param temp 目标节点中储存的双精度浮点值
|
||||||
|
@return 返回包含所有符合条件的节点的新的重组链表
|
||||||
|
*/
|
||||||
List *mply_findByDouble(List* p_list, double temp) {
|
List *mply_findByDouble(List* p_list, double temp) {
|
||||||
List *t_list;
|
List *t_list;
|
||||||
double *p_temp = (double *)malloc(sizeof(double));
|
double *p_temp = (double *)malloc(sizeof(double));
|
||||||
@ -61,6 +107,13 @@ List *mply_findByDouble(List* p_list, double temp) {
|
|||||||
return t_list;
|
return t_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的字符串值来找到链表中所有符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param temp 目标节点中储存的字符串值
|
||||||
|
@return 返回包含所有符合条件的节点的新的重组链表
|
||||||
|
*/
|
||||||
List *mply_findByString(List* p_list, char *temp) {
|
List *mply_findByString(List* p_list, char *temp) {
|
||||||
List *t_list;
|
List *t_list;
|
||||||
char *p_temp = (char *)malloc(sizeof(char)*(strlen(temp) + 1));
|
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;
|
return t_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过节点中储存的指针值来找到链表中所有符合条件的节点
|
||||||
|
|
||||||
|
@param p_list 指向目标链表的指针
|
||||||
|
@param temp 目标节点中储存的指针值
|
||||||
|
@return 返回包含所有符合条件的节点的新的重组链表
|
||||||
|
*/
|
||||||
List *mply_findByPointer(List* p_list, void *temp) {
|
List *mply_findByPointer(List* p_list, void *temp) {
|
||||||
List *t_list = mply_findByValue(p_list, DOUBLE, (void *)temp);
|
List *t_list = mply_findByValue(p_list, DOUBLE, (void *)temp);
|
||||||
return t_list;
|
return t_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
List *mply_findByIntForNode(List* p_list, int temp) {
|
|
||||||
int *p_temp = (int *)malloc(sizeof(int));
|
/**
|
||||||
if(p_temp == NULL){
|
通过节点中储存的整型值来找到链表中所有符合条件的节点
|
||||||
return NULL;
|
|
||||||
}
|
@param p_list 指向目标链表的指针
|
||||||
*p_temp = temp;
|
@param temp 目标节点中储存的整型值
|
||||||
return mply_findByValue(p_list, INT, (void *)p_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;
|
@param p_list 指向目标链表的指针
|
||||||
}
|
@param temp 目标节点中储存的双精度浮点值
|
||||||
*p_temp = temp;
|
@return 返回包含所有符合条件的节点的新的重组链表
|
||||||
return mply_findByValue(p_list, DOUBLE, (void *)p_temp);
|
*/
|
||||||
|
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;
|
@param p_list 指向目标链表的指针
|
||||||
}
|
@param temp 目标节点中储存的字符串值
|
||||||
strcpy(p_temp, temp);
|
@return 返回包含所有符合条件的节点的新的重组链表
|
||||||
return mply_findByValue(p_list, STRING, (void *)p_temp);
|
*/
|
||||||
|
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) {
|
Node *findByIndexForNode(List *p_list, unsigned long long m_index) {
|
||||||
if(p_list == NULL) return NULL;
|
if(p_list == NULL) return NULL;
|
||||||
|
//当长链表模式可能启用时编译以下语句
|
||||||
#ifdef list_quick_enable
|
#ifdef list_quick_enable
|
||||||
if(p_list->p_lq != NULL){
|
if(p_list->p_lq != NULL){
|
||||||
register struct list_quick *p_lq = p_list->p_lq;
|
register struct list_quick *p_lq = p_list->p_lq;
|
||||||
|
@ -1,27 +1,53 @@
|
|||||||
#include <type.h>
|
#include <type.h>
|
||||||
#include <list/list.h>
|
#include <list/list.h>
|
||||||
#include <list/list_expand.h>
|
#include <list/list_expand.h>
|
||||||
|
//长链表模式可能启用则包含以下头文件
|
||||||
#ifdef list_quick_enable
|
#ifdef list_quick_enable
|
||||||
#include <list/list_quick.h>
|
#include <list/list_quick.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*直接获得节点中储存的字符串值*/
|
/**
|
||||||
|
直接获得节点中储存的字符串
|
||||||
|
|
||||||
|
@param p_node 指向目标节点的指针
|
||||||
|
@return 返回节点中储存的字符串
|
||||||
|
*/
|
||||||
char *getByStringForNode(Node *p_node) {
|
char *getByStringForNode(Node *p_node) {
|
||||||
if (p_node->type == STRING) return (char *)(p_node->value);
|
if (p_node->type == STRING) return (char *)(p_node->value);
|
||||||
else return NULL;
|
else return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
直接获得节点中储存的双精度浮点值
|
||||||
|
|
||||||
|
@param p_node 指向目标节点的指针
|
||||||
|
@return 返回节点中储存的双精度浮点值
|
||||||
|
*/
|
||||||
double getByDoubleForNode(Node *p_node) {
|
double getByDoubleForNode(Node *p_node) {
|
||||||
if (p_node->type == DOUBLE) return *(double *)(p_node->value);
|
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) {
|
void *getByPointerForNode(Node *p_node) {
|
||||||
return (void *)(p_node->value);
|
return (void *)(p_node->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
通过链表中相应的节点获得其在链表中的排列序号
|
||||||
|
|
||||||
|
@param p_list 指向目标链表
|
||||||
|
@param p_node 指向目标节点的指针
|
||||||
|
@return 成功返回相应排列序号,失败则会返回0
|
||||||
|
*/
|
||||||
unsigned long long getIndexByNode(List *p_list, Node *p_node) {
|
unsigned long long getIndexByNode(List *p_list, Node *p_node) {
|
||||||
|
// 长链表模式可能启用则编译以下代码
|
||||||
#ifdef list_quick_enable
|
#ifdef list_quick_enable
|
||||||
if (p_list->p_lq != NULL){
|
if (p_list->p_lq != NULL){
|
||||||
register Node **p_fn_node = p_list->p_lq->fn_node;
|
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 Node *t_node = p_list->head;
|
||||||
register unsigned long long index = 0;
|
register unsigned long long index = 0;
|
||||||
while (t_node != NULL) {
|
while (t_node != NULL) {
|
||||||
|
// id模块可能启用的时候则编译以下代码
|
||||||
#ifdef id_enable
|
#ifdef id_enable
|
||||||
if (p_node->s_id == t_node->s_id) return index;
|
if (p_node->s_id == t_node->s_id) return index;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user