void SetUpNode() {
for (int y = 0; y < squrePerRow; ++y) {
for (int x = 0; x < squrePerRow; ++x) {
Vector2 position = Vector2(x,y);
int cost = 5;
allNodes.insert(pair<Vector2,int>(position,cost));
}
}
}
When I setUpNode, only the 10 node can be insert to the map.
I am not that familiar with map. what i did rwong? How can I solve it?
The map doesn't store duplicate keys. Your comparison function fncomp only compares the x coordinates so all vectors that has the same x value will be considered equal, no matter what the value of y is. You try to insert 100 elements but there are only 10 unique x values so that is why only 10 elements are inserted.