Skip to main content
gamedev.net
🔒 Locked

pointer class hierarchy

Started by chaosgame 0 replies 1k views
Original Post
chaosgame
chaosgame
I decided that today I would do an implementation of a mathematical graph. The graph would be composed of node objects, with each node containing its own data, and pointers to multiple other nodes. To make the class even more useful, the next() function would take an input variable and return only the nodes that are reachable by that variable. For example it would look something like:
Node--(if( variable==key))-->Next Node
This way I could create a NFA subclass. I would need to create my own test_pointer class that would test the path before pointing to the next object. This would be a subclass of pointer. Since the graph would have nodes pointing to multiple other nodes, I would need a multi_pointer class that would point to multiple objects. I would like to know how this sounds and the best way to implement the multi_pointer class. I think that I am going to use std::set because it doesn't have multiple copies of the same value in it.
"Are you threatening me, Master Jedi?" - Chancellor Palpatine
JohnBolton
JohnBolton
I would use a std::multimap to store the pointers. The multimap has the property that a key (the input) can be associated with multiple values (the pointers). It also allows multiple keys to be associated the same pointer (actually multiple copies of the pointer).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.