summaryrefslogtreecommitdiff
path: root/src/SSystem/SComponent/c_node_iter.cpp
blob: 5eeb939ad4056f2377e6b113cccdafe61c5f5d99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * c_node_iter.cpp
 *
 */

#include "SSystem/SComponent/c_node_iter.h"
#include "SSystem/SComponent/c_node.h"
#include <types.h>

int cNdIt_Method(node_class* node, cNdIt_MethodFunc method, void* data) {
    int ret = 1;
    node_class* pNext = NODE_GET_NEXT(node);

    while (node) {
        if (!method(node, data))
            ret = 0;
        node = pNext;
        pNext = NODE_GET_NEXT(pNext);
    }

    return ret;
}

void* cNdIt_Judge(node_class* node, cNdIt_JudgeFunc judge, void* data) {
    node_class* pNext = NODE_GET_NEXT(node);

    while (node) {
        void* ret = judge(node, data);
        if (ret != NULL)
            return ret;
        node = pNext;
        pNext = NODE_GET_NEXT(pNext);
    }

    return NULL;
}