开发者

creating a list of queues

I am working on a simulation. For this simulation I need 20 nodes (static) and then each node has a queue associated with it. This queue could hold any number of values. What would be the best way to implement 开发者_运维知识库this in C? I was aiming at having each of the queues being a simple linked list, but how can I effectively create several queues, one for each node??

Thanks, Any help would be most appreciated


Basically, you need to create one struct for the queue, which is a simple linked list:

typedef struct queue_t {
    int data; /* the date in the queue, can be anything, not only an int */
    struct queue_t* next; /* pointer to the next in the queue */
} queue_t;

And then another one is the list of 20 queues:

queue_t *list_of_queues[20];

That's the simplest way to go about it, IMHO.

Edit: Made the array of structs into an array of pointers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜