One more STL question about vectors and maps

scootermaster

Platinum Member
Nov 29, 2005
2,411
0
0
So I need to associate a pointer with two integers. For the curious, it's a pointer to an edge in a graph, a weight associated with that edge, and a flag about the status of the edge. The edges will all be unique.

Anyway, it would be nice if I could do something like this:

map<edge *, int, int> nodes;

But that doesn't work. Now, I thought I could do something involving pairs or something, but that doesn't seem to work.

The closest I can get is making a vector, and then loading up the vector and then putting in in the map. The problems with that are, a) there's no explicit marshalling of the values there; I have to make sure I put them in the vector in the correct order, and b) I have to [seemingly] declare a new vector object (and fill it) every time I want to make a new/different map entry, which is a lot more work than just saying

map.insert(pair<edge *, int, int>(myEdge, 0, 1)) or whatever.

So first off, does a map even make sense here? I could define my own struct, but I'd like to leverage all that STL has to offer (like how many elements are in the map and all that).

Any ideas? It doesn't seem THAT hard to do.

Thanks!
 

scootermaster

Platinum Member
Nov 29, 2005
2,411
0
0
Figured out how to do it using pair.

Sorta nifty, that whole STL thing!

(Pardon my newbness to all of this)