diff --git a/core/indigo-core/layout/src/molecule_layout.cpp b/core/indigo-core/layout/src/molecule_layout.cpp index 8c10d4659e..d2cbac0c40 100644 --- a/core/indigo-core/layout/src/molecule_layout.cpp +++ b/core/indigo-core/layout/src/molecule_layout.cpp @@ -71,7 +71,7 @@ void MoleculeLayout::_init(bool smart_layout) // modify the atom mapping for (int j = 0; j < _atomMapping.size(); ++j) - if (atomMapCollapse.find(_atomMapping[j])) + if (atomMapCollapse.find(_atomMapping[j]) != atomMapCollapse.end()) _atomMapping[j] = atomMapCollapse.at(_atomMapping[j]); } } diff --git a/core/indigo-core/molecule/base_molecule.h b/core/indigo-core/molecule/base_molecule.h index ca879b4aaf..c48352ad14 100644 --- a/core/indigo-core/molecule/base_molecule.h +++ b/core/indigo-core/molecule/base_molecule.h @@ -34,6 +34,7 @@ #include "molecule/molecule_stereocenters.h" #include "molecule/molecule_tgroups.h" #include +#include #ifdef _WIN32 #pragma warning(push) @@ -104,7 +105,7 @@ namespace indigo class DLLEXPORT BaseMolecule : public Graph { public: - typedef RedBlackMap Mapping; + typedef std::map Mapping; BaseMolecule(); ~BaseMolecule() override; @@ -462,7 +463,7 @@ namespace indigo Array _bond_directions; Array _xyz; - RedBlackMap _stereo_flag_positions; + std::map _stereo_flag_positions; ObjArray> _rsite_attachment_points; bool _rGroupFragment; diff --git a/core/indigo-core/molecule/src/base_molecule.cpp b/core/indigo-core/molecule/src/base_molecule.cpp index 705976f0ac..25d257acdb 100644 --- a/core/indigo-core/molecule/src/base_molecule.cpp +++ b/core/indigo-core/molecule/src/base_molecule.cpp @@ -1231,10 +1231,10 @@ void BaseMolecule::collapse(BaseMolecule& bm, int id, Mapping& mapAtom, Mapping& int from = group.atoms[j]; int to = group.atoms[k]; - int* to_ = mapAtom.at2(from); - if (to_ == 0) - mapAtom.insert(from, to); - else if (*to_ != to) + auto it = mapAtom.find(from); + if (it == mapAtom.end()) + mapAtom.emplace(from, to); + else if (it->second != to) throw Error("Invalid mapping in MultipleGroup::collapse"); if (k != j) @@ -1244,15 +1244,15 @@ void BaseMolecule::collapse(BaseMolecule& bm, int id, Mapping& mapAtom, Mapping& for (int j = bm.edgeBegin(); j < bm.edgeEnd(); j = bm.edgeNext(j)) { const Edge& edge = bm.getEdge(j); - bool in1 = mapAtom.find(edge.beg), in2 = mapAtom.find(edge.end), p1 = in1 && mapAtom.at(edge.beg) == edge.beg, - p2 = in2 && mapAtom.at(edge.end) == edge.end; + bool in1 = mapAtom.find(edge.beg) != mapAtom.end(), in2 = mapAtom.find(edge.end) != mapAtom.end(); + bool p1 = in1 && mapAtom.at(edge.beg) == edge.beg, p2 = in2 && mapAtom.at(edge.end) == edge.end; if ((in1 && !p1 && !in2) || (!in1 && !p2 && in2)) { int beg = in1 ? mapAtom.at(edge.beg) : edge.beg; int end = in2 ? mapAtom.at(edge.end) : edge.end; int bid = copyBaseBond(bm, beg, end, j); - if (!mapBondInv.find(bid)) - mapBondInv.insert(bid, j); + if (mapBondInv.find(bid) == mapBondInv.end()) + mapBondInv.emplace(bid, j); } } @@ -4137,7 +4137,7 @@ void BaseMolecule::setStereoFlagPosition(int frag_index, const Vec3f& pos) { try { - _stereo_flag_positions.insert(frag_index, pos); + _stereo_flag_positions.emplace(frag_index, pos); } catch (Exception& ex) { @@ -4146,10 +4146,10 @@ void BaseMolecule::setStereoFlagPosition(int frag_index, const Vec3f& pos) bool BaseMolecule::getStereoFlagPosition(int frag_index, Vec3f& pos) { - auto pval = _stereo_flag_positions.at2(frag_index); - if (pval) + auto it = _stereo_flag_positions.find(frag_index); + if (it != _stereo_flag_positions.end()) { - pos = *pval; + pos = it->second; return true; } return false; diff --git a/core/render2d/src/render_internal.cpp b/core/render2d/src/render_internal.cpp index 6e7d02f95c..500e5d0cb9 100644 --- a/core/render2d/src/render_internal.cpp +++ b/core/render2d/src/render_internal.cpp @@ -855,7 +855,7 @@ void MoleculeRenderInternal::_cloneAndFillMappings() _bondMappingInv.clear(); for (int i = clone->edgeBegin(); i < clone->edgeEnd(); i = clone->edgeNext(i)) { - _bondMappingInv.insert(i, BaseMolecule::findMappedEdge(*clone, *_mol, i, _atomMappingInv.ptr())); + _bondMappingInv.emplace(i, BaseMolecule::findMappedEdge(*clone, *_mol, i, _atomMappingInv.ptr())); } _mol = clone; _own_mol = true; @@ -928,9 +928,9 @@ void MoleculeRenderInternal::_prepareSGroups() bid = amol.addBond(said, naid, amol.getBondOrder(nbid)); amol.setEdgeTopology(bid, amol.getBondTopology(nbid)); } - if (_bondMappingInv.find(bid)) - _bondMappingInv.remove(bid); - _bondMappingInv.insert(bid, _bondMappingInv.at(nbid)); + if (_bondMappingInv.find(bid) != _bondMappingInv.end()) + _bondMappingInv.erase(bid); + _bondMappingInv.emplace(bid, _bondMappingInv.at(nbid)); } } }