Man page BSD的queue.h清楚地显示了如何创建单链表/双链表/尾队列,但我不知道如何创建例如列表列表或队列队列?特别是,如何处理从属查询的声明和初始化?
我尝试了什么:
//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
我花了一些时间才明白如何处理这个问题,所以这个问题几天前就出现在这里。
关于c - 队列.h : how to create list of lists/queue of queues/similar combinations?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39409785/