src/llist.h: Add LLIST_{,TS}_FIND_FOREACH_CONT
In contrast to LLIST_{,TS}_FIND_FOREACH, these convenience macros search for the first match and return successors until there is an item that isn't matched by the filter callback. Any items beyond the first cut-off are discarded. Should be used when results are known to be continuous, such as appointments and events belonging to a specific day etc. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
1fa9564916
commit
9c1cbbdb22
@ -86,6 +86,9 @@ llist_item_t *llist_find_nth (llist_t *, int, long, llist_fn_match_t);
|
||||
#define LLIST_FIND_FOREACH(l, data, fn_match, i) \
|
||||
for (i = LLIST_FIND_FIRST (l, data, fn_match); i; \
|
||||
i = LLIST_FIND_NEXT (i, data, fn_match))
|
||||
#define LLIST_FIND_FOREACH_CONT(l, data, fn_match, i) \
|
||||
for (i = LLIST_FIND_FIRST (l, data, fn_match); i; \
|
||||
i = LLIST_NEXT_FILTER (i, data, fn_match))
|
||||
|
||||
/* Accessing list item data. */
|
||||
void *llist_get_data (llist_item_t *);
|
||||
|
@ -78,6 +78,9 @@ struct llist_ts {
|
||||
#define LLIST_TS_FIND_FOREACH(l_ts, data, fn_match, i) \
|
||||
for (i = LLIST_TS_FIND_FIRST (l_ts, data, fn_match); i; \
|
||||
i = LLIST_TS_FIND_NEXT (i, data, fn_match))
|
||||
#define LLIST_TS_FIND_FOREACH_CONT(l_ts, data, fn_match, i) \
|
||||
for (i = LLIST_TS_FIND_FIRST (l_ts, data, fn_match); i; \
|
||||
i = LLIST_TS_NEXT_FILTER (i, data, fn_match))
|
||||
|
||||
/* Accessing list item data. */
|
||||
#define LLIST_TS_GET_DATA(i) llist_get_data (i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user