Skip to content

Commit 1dea10a

Browse files
Mikalai SukhikhMikalai Sukhikh
Mikalai Sukhikh
authored and
Mikalai Sukhikh
committed
Issue #521: core: replace MultiMap with standard library container
Partial implementation: replace MultiMap in MoleculeRGroupsComposition class - Part 2
1 parent 1d1e43c commit 1dea10a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

core/indigo-core/molecule/molecule_rgroups_composition.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#ifndef __molecule_rgroups_composition__
2020
#define __molecule_rgroups_composition__
2121

22+
#include <map>
2223
#include <memory>
2324

2425
#include "base_cpp/array.h"
25-
#include "base_cpp/multimap.h"
2626
#include "molecule/molecule.h"
2727

2828
namespace indigo
@@ -240,13 +240,13 @@ namespace indigo
240240

241241
inline Fragment _fragment_coordinates(int rsite, int fragment) const
242242
{
243-
const RedBlackSet<int>& rs = _rsite2rgroup[_rsite2vertex.at(rsite)];
244-
245243
int r = -1;
246244
int f = fragment;
247-
for (int i = rs.begin(); i != rs.end(); i = rs.next(i))
245+
const auto it_end = _rsite2rgroup.upper_bound(_rsite2vertex.at(rsite));
246+
247+
for (auto it = _rsite2rgroup.lower_bound(_rsite2vertex.at(rsite)); it != it_end; it++)
248248
{
249-
r = rs.key(i);
249+
r = it->second;
250250
int size = _rgroup2size[r];
251251
if (f >= size)
252252
{
@@ -281,7 +281,7 @@ namespace indigo
281281

282282
Array<int> _limits;
283283
Array<int> _rgroup2size;
284-
MultiMap<int, int> _rsite2rgroup;
284+
std::multimap<int, int> _rsite2rgroup;
285285
RedBlackMap<int, int> _rsite2vertex;
286286

287287
mutable std::unique_ptr<Attachments> _ats;

core/indigo-core/molecule/src/molecule_rgroups_composition.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
* limitations under the License.
1717
***************************************************************************/
1818

19-
#include <map>
20-
2119
#include "base_cpp/array.h"
2220
#include "molecule/base_molecule.h"
2321

@@ -44,7 +42,10 @@ MoleculeRGroupsComposition::MoleculeRGroupsComposition(BaseMolecule& mol)
4442

4543
Array<int> rgroups;
4644
_mol.getAllowedRGroups(vertex, rgroups);
47-
_rsite2rgroup.insert(vertex, rgroups);
45+
for (const auto& rgroup : rgroups)
46+
{
47+
_rsite2rgroup.emplace(vertex, rgroup);
48+
}
4849

4950
int total = 0;
5051
for (int i = 0; i < rgroups.size(); i++)

0 commit comments

Comments
 (0)