I try to use a map which is defined as :
map<Vertex,unsigned int> _addedVertices;
now when I use the find function to check if a vertex is already inside I get an iterator to a wrong vertex with different information, so I have tried the following :
map<Vertex,unsigned int,cmpByVertexFields> _addedVertices;
which didn't help.
also I have the following overloaded functions inside the Vertex class.
bool operator<(const Vertex &otherV)const{
return(_x<otherV._x && _y<otherV._y && _z<otherV._z);
}
bool operator==(const Vertex &otherV)const{
return _x==otherV._x && _y==otherV._y && _z==otherV._z;
}
but nothing works. Example: I've inserted a vertex containing (0.2,0.1,0.4) and next thing I use is the find function with (0.2,0.15,0.41) the iterator I get is of the first vertex instead of map.end().
What did I forget to define? Thanks
edit: cmpByVertexFields :
struct cmpByVertexFields {
bool operator()(const Vertex& a, const Vertex& b) const {
return a.getX()==b.getX() &&
a.getY()==b.getY() &&
a.getZ()==b.getZ();
}
};