次のように定義されているマップを使用しようとしています。
map<Vertex,unsigned int> _addedVertices;
find 関数を使用して頂点が既に内部にあるかどうかを確認すると、異なる情報を持つ間違った頂点への反復子が取得されるため、次のことを試しました。
map<Vertex,unsigned int,cmpByVertexFields> _addedVertices;
これは役に立ちませんでした。
また、Vertex クラス内に次のオーバーロードされた関数があります。
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;
}
しかし、何も機能しません。例: (0.2,0.1,0.4) を含む頂点を挿入しました。次に使用するのは、(0.2,0.15,0.41) を使用した検索関数です。取得する反復子は、map.end() ではなく最初の頂点です。
何を定義するのを忘れましたか? ありがとう
編集: 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();
}
};