BSD的queue.h手册页清楚地显示了如何创建单/双链表/尾队列,但我不能得到如何创建,例如,列表的列表或队列的队列?特别是,如何处理从查询的声明和初始化?
What did I try:
//element of slave queue
struct slaveentry {
STAILQ_ENTRY(slaveentry) pts; //pointers
/*data here*/
} *selt; //element of queue
//element of master queue
struct masterentry {
STAILQ_ENTRY(masterentry) pts; //pointers
struct slavehead *slave; //pointer to slave queue head
/*data here*/
} *melt; //element of queue
//initialization of sturctures
STAILQ_HEAD(masterhead, masterentry) big_queue = STAILQ_HEAD_INITIALIZER(big_queue);
STAILQ_INIT(&big_queue);
//what's next? I don't know, maybe some sort of the following
STAILQ_HEAD(slavehead, slaveentry) small_queue = STAILQ_HEAD_INITIALIZER(small_queue);
STAILQ_INIT(&small_queue);
如果您对解决方案感兴趣,可以在这里查看:https://gist.github.com/postboy/fb825b9fe813a0a18d04ef4cdf2ac7a0
我花了一些时间才明白如何处理这个问题,所以这个问题几天前出现在这里