Hello! ... and thanks for reading...
I'm still learning the ropes so please be forgiving... ;-)
I am writing a function that meshes a solid in space. The mesh is done by using objects of a "Node" class and each node is represented by:
int id
double p
double r
Initially I thought that a map would be the way to go: with a map I can make the association between the "id" key and the second key (a pointer to the node object).
Something like this:
int nodeId;
Node *node;
std::map<int, Node *> NodeMap;
Then, when I create the nodes I just call the "new" operator. E.g in a for loop I do something like this:
node = new Node(i); // the node constructor sets the id to the value of i.
and I add the new node to the map:
NodeMap[i] = node;
But.... I realized that I will need to do a lookup in the map not by first key (the id) but by the p and r parameters (the coordinates of the node).
In other words I will need something that returns the node id given the values of p and r. A map is a perfect container if the lookup is done using the integer first key (id). Does anyone have a suggestion on how to solve this particular problem?
Thanks much! AsvP.