35 lines
626 B
C
35 lines
626 B
C
#include <ordinary/idx.h>
|
|
#include <stdlib.h>
|
|
|
|
struct ordinary_node *ordinary_list_find(struct ordinary_list *list, ordinary_cb cb) {
|
|
struct ordinary_node *node = list->head;
|
|
uint32_t idx = 0;
|
|
|
|
for(; node; node = node->next) {
|
|
if(cb(node, idx)) {
|
|
return node;
|
|
}
|
|
|
|
if(list->limit) {
|
|
idx += 1;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
uint8_t ordinary_list_for(struct ordinary_list *list, ordinary_cb cb) {
|
|
struct ordinary_node *node = list->head;
|
|
uint32_t idx = 0, res = 0;
|
|
|
|
for(; node; node = node->next) {
|
|
res |= cb(node, idx);
|
|
|
|
if(list->limit) {
|
|
idx += 1;
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|