Re: New to STL
breck wrote:
Hi, I'm working on a program in which I want to store instances of
Cubes in a hash_set and pointers to those cubes in Nodes (the nodes are
stored in a priority queue).
My code looks something like this:
std::hash_set <Cube, hashFunc<Cube>, equals> cubesVisited;
std::priority_queue <Node, std::vector<Node>, comp> nodesToExpand;
std::pair<std::hash_set <Cube>::iterator, bool> p;
p = cubesVisited.insert(Cube(currentState).turnFrontCW());
if (p.second)
nodesToExpand.push(Node(*pointer to what was just inserted in the hash
table*, n));
I'm not sure how to access that memory location. I know to get the
value of the Cube I would put *p, but I just want p (not the iterator,
but the memory location the iterator is pointing to). Do I even get at
it through the iterator? Is there some other way? Thanks for any help
in advance.
Note that hash_set is currently not standard.
If I understand your question, I think what you want is &*(p->first).
-Mark