Add TAILQ_FOREACH_REVERSE() macro.
Submitted by: Jake Burkholder <jburkhol@home.com>
This commit is contained in:
parent
7892318c65
commit
2be85d6dac
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59861
@ -74,7 +74,7 @@
|
|||||||
* linked so that an arbitrary element can be removed without a need to
|
* linked so that an arbitrary element can be removed without a need to
|
||||||
* traverse the list. New elements can be added to the list before or
|
* traverse the list. New elements can be added to the list before or
|
||||||
* after an existing element, at the head of the list, or at the end of
|
* after an existing element, at the head of the list, or at the end of
|
||||||
* the list. A tail queue may only be traversed in the forward direction.
|
* the list. A tail queue may be traversed in either direction.
|
||||||
*
|
*
|
||||||
* A circle queue is headed by a pair of pointers, one to the head of the
|
* A circle queue is headed by a pair of pointers, one to the head of the
|
||||||
* list and the other to the tail of the list. The elements are doubly
|
* list and the other to the tail of the list. The elements are doubly
|
||||||
@ -97,6 +97,7 @@
|
|||||||
* _PREV - - - + +
|
* _PREV - - - + +
|
||||||
* _LAST - - + + +
|
* _LAST - - + + +
|
||||||
* _FOREACH + + + + +
|
* _FOREACH + + + + +
|
||||||
|
* _FOREACH_REVERSE - - - + +
|
||||||
* _INSERT_HEAD + + + + +
|
* _INSERT_HEAD + + + + +
|
||||||
* _INSERT_BEFORE - + - + +
|
* _INSERT_BEFORE - + - + +
|
||||||
* _INSERT_AFTER + + + + +
|
* _INSERT_AFTER + + + + +
|
||||||
@ -332,6 +333,11 @@ struct { \
|
|||||||
#define TAILQ_FOREACH(var, head, field) \
|
#define TAILQ_FOREACH(var, head, field) \
|
||||||
for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
|
for (var = TAILQ_FIRST(head); var; var = TAILQ_NEXT(var, field))
|
||||||
|
|
||||||
|
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
|
||||||
|
for ((var) = TAILQ_LAST((head), headname); \
|
||||||
|
(var); \
|
||||||
|
(var) = TAILQ_PREV((var), headname, field))
|
||||||
|
|
||||||
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
#define TAILQ_FIRST(head) ((head)->tqh_first)
|
||||||
|
|
||||||
#define TAILQ_LAST(head, headname) \
|
#define TAILQ_LAST(head, headname) \
|
||||||
|
Loading…
Reference in New Issue
Block a user