Point is a struct of the form:
typedef struct Point {
int x;
int y;
bool operator<(const Point &other) const
{
return ((this->x < other.x) && (this->y < other.y));
};
bool operator!=(const Point &other) const
{
return ((this->x != other.x) || (this->y != other.y));
}
bool operator==(const Point &other) const
{
return ((this->x == other.x) && (this->y == other.y));
}
} Point;
and I'm using:
map<Point,int> points;
the map is initialized with {{0,0},1}. and the program used points.count(p) to check whether the point p is a key in the points map.
There's a problem and the program always returns yes! even for points not in the map. I mean if p is not a key in points, I'm getting points.count(p)==1 (and not 0).
Also, when using points.find(p) to get the iterator to check whether the received point is really ==0 (it is not), I'm getting a reference to a totally different point..
Any idea how to fix the problem?