samedi 28 mars 2015

Can a linked list node contain more than one data field?



I'm rather asking if it makes sense to do this. I have not seen any examples of this but I haven't seen anything that goes against this idea.


I am in a publisher-subscriber model, so the idea I have so far is: I create a list of topics, that are added from a certain file.


But instead of simply having each name of the topic and the pointer to the next topic, I kind of wanted to have a node of suscribers to each topic, in each topic's node.


Since I'm probably explaining myself poorly, this would be the idea:



struct topicNode{
char * topicName; //I believe there is no problem with pointers in a lists but again, I have not seen anyone doing it either so...

struct suscriberNode;
struct topicNode next;
};


And so I would make, if there's any suscriber to a certain topic, a list of suscribers for that topic. I've done similar things to this in Java, but I'm worried it's not such a good idea to this in C.




Aucun commentaire:

Enregistrer un commentaire