|
|
|
|
|
|
|
|
|
|
|
|
**it == *pCalc
If you want to search for an object then you will need to **it == *pCalc |
So it makes sense to search for a pointer |
The pointers in the vector could be anything |
Don't understand what you mean. The vector will have what you put it in. |
|
|
|
|
By instance, you may want the neighbours of a region, and you do need pointers because you want to communicate with them. Also you want the neighbours, not some nodes that compare equal to them. It's a collection of pointers, ¿what's so weird? |
Instead of that, I decide to store a unique ID for every node ¿what would be the difference? |
The way to finish this, is for the OP to test the code. |
Furthermore, the find algorithm I posted above is a built in solution, so just use that. |
What you are trying to do is a find function that looks for something in a vector, that may or may not be there. If it is, put it on the list. |
I am saying this won't work using a raw pointer as the search value because the vector is going to have it's own pointers which will be different to pCalc. This could be verified by printing the value of pCalc, then printing the value of the iterator pointer as it goes round the loop. |
*it == pCalc
The pointers in the vector could be anything. The only way this would work would be if you knew what the pointer was in the vector, if that was the case then it negates the entire discussion, because you already have it , so put it on the list. |
I am going to stick my neck out and predict that it will never work if a search for raw pointer is used, and it will only work with dereferencing and comparing. |
Furthermore, the find algorithm I posted above is a built in solution, so just use that. |
In the third possible solution (AddToList3) i am already using the find algoritm! (but thanx anyway :) ) |
|
|
but still DIFFERENT objects |
Is RTTI a solution to test for objects of the same type? |
|
|