I am trying to use an iterator find() to retrieve the pointer to a node class that contains a certain value.
Is there a better way than doing something like this?
typedef vector<Node*> Vmap;
Vmap vmap;
for(Vmap::iterator itr = vmap.begin(); itr != vmap.end(); itr++) {
if((*itr)->getVal() == 3) {
// do something
}
}
Desired:
Vmap::iterator itr = find(vmap.begin(), vmap.end, 3) // return Node pointer with value == 3
Node* temp_node = *itr
Thank you
EDIT: Additional information to supplement given answer.