请大家帮忙对qLib.h的几个宏函数解释一下?
* Q_FIRST - return first node in multi-way queue
*
* This routine returns a pointer to the first node in the specified multi-way
* queue head. If the queue is empty, NULL is returned.
*
* RETURNS
* Pointer to first queue node in queue head, or
* NULL if queue is empty.
*
* NOMANUAL
*/
#define Q_FIRST(pQHead)\
((Q_NODE *)(((Q_HEAD *)(pQHead))->pFirstNode))
* Q_PUT - insert a node into a multi-way queue
*
* This routine inserts a node into a multi-way queue. The insertion is based
* on the key and the underlying queue class.
*
* NOMANUAL
*/
#define Q_PUT(pQHead,pQNode,key)\
(*(((Q_HEAD *)(pQHead))->pQClass->putRtn))\
(((Q_HEAD *)(pQHead)), ((Q_NODE *)(pQNode)), (key))
* Q_REMOVE - remove a node from a multi-way queue
*
* This routine removes a node from the specified multi-way queue.
*
* NOMANUAL
*/
#define Q_REMOVE(pQHead,pQNode)\
(*(((Q_HEAD *)(pQHead))->pQClass->removeRtn))\
(((Q_HEAD *)(pQHead)), ((Q_NODE *)(pQNode)))
* Q_EACH - call a routine for each node in a queue
*
* This routine calls a user-supplied routine once for each node in the
* queue. The routine should be declared as follows:
* .CS
* BOOL routine (pQNode, arg)
* Q_NODE*pQNode;* pointer to a queue node *
* intarg;* arbitrary user-supplied argument *
* .CE
* The user-supplied routine should return TRUE if qEach (2) is to continue
* calling it for each entry, or FALSE if it is done and qEach can exit.
*
* RETURNS: NULL if traversed whole queue, or pointer to Q_NODE that
* qEach ended with.
*
* NOMANUAL
*/
#define Q_EACH(pQHead,routine,routineArg)\
((Q_NODE *)((*(((Q_HEAD *)(pQHead))->pQClass->eachRtn))\
(((Q_HEAD *)(pQHead)),((FUNCPTR)(routine)),((int)(routineArg)))))
这几个宏的结构很类似,意思也明白。但是代码读的似懂非懂,有大侠给解释一下么?
[解决办法]
都是宏定义:
可以直接替代看,就一目了然了。
[解决办法]
麻烦帮我分析一下其中一个的结构吧,C看的不太明白