Files
tp/libs/SSystem/SComponent/c_node_iter.cpp
T

39 lines
899 B
C++
Raw Normal View History

2020-11-30 14:26:55 -08:00
#include "SComponent/c_node_iter.h"
2020-12-26 11:31:49 -05:00
#include "global.h"
2020-11-30 14:26:55 -08:00
extern "C" {
#define NODE_GET_PREV(pNode) (pNode ? pNode->mpPrevNode : NULL)
#define NODE_GET_NEXT(pNode) (pNode ? pNode->mpNextNode : NULL)
2020-12-26 11:31:49 -05:00
int cNdIt_Method(node_class* pNode, cNdIt_MethodFunc pMethod, void* pUserData) {
2020-11-30 14:26:55 -08:00
int ret = 1;
2020-12-26 11:31:49 -05:00
node_class* pNext = NODE_GET_NEXT(pNode);
2020-11-30 14:26:55 -08:00
while (pNode) {
int methodRet = pMethod(pNode, pUserData);
if (!methodRet)
ret = 0;
pNode = pNext;
pNext = NODE_GET_NEXT(pNext);
}
return ret;
}
2020-12-26 11:31:49 -05:00
void* cNdIt_Judge(node_class* pNode, cNdIt_JudgeFunc pJudge, void* pUserData) {
node_class* pNext = NODE_GET_NEXT(pNode);
2020-11-30 14:26:55 -08:00
while (pNode) {
2020-12-26 11:31:49 -05:00
void* pJudgeRet = pJudge(pNode, pUserData);
2020-11-30 14:26:55 -08:00
if (pJudgeRet != NULL)
return pJudgeRet;
pNode = pNext;
pNext = NODE_GET_NEXT(pNext);
}
return NULL;
}
};