Skip to content

Commit

Permalink
Issue #521: core: replace MultiMap with standard library container
Browse files Browse the repository at this point in the history
Partial implementation: replace MultiMap in MoleculeRGroupsComposition class - Part 2
  • Loading branch information
Mikalai Sukhikh authored and Mikalai Sukhikh committed Dec 6, 2022
1 parent 1d1e43c commit d119d96
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 9 additions & 9 deletions api/tests/integration/ref/composition/basic.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -367,15 +367,15 @@ molecule 01: C1(C2CCCC2)=C(C2CCCC2)C=CC=C1 |RG:_R1={C1CCCC1},{C1CCCC1}|
fragment 1: C1CCCC1
fragment 2: C1CCCC1
===================================================
molecule 02: C1(C2CCCCC2)=C(C2CCCC2)C=CC=C1 |RG:_R1={C1CCCCC1},{C1CCCC1}|
molecule 02: C1(C2CCCCC2)=C(C2CCCC2)C=CC=C1 |RG:_R1={C1CCCC1},{C1CCCCC1}|
rgroup 1
fragment 1: C1CCCCC1
fragment 2: C1CCCC1
fragment 1: C1CCCC1
fragment 2: C1CCCCC1
===================================================
molecule 03: C1(C2=CC=CC=C2)=C(C2CCCC2)C=CC=C1 |RG:_R1={C1=CC=CC=C1},{C1CCCC1}|
molecule 03: C1(C2=CC=CC=C2)=C(C2CCCC2)C=CC=C1 |RG:_R1={C1CCCC1},{C1=CC=CC=C1}|
rgroup 1
fragment 1: C1=CC=CC=C1
fragment 2: C1CCCC1
fragment 1: C1CCCC1
fragment 2: C1=CC=CC=C1
===================================================
molecule 04: C1(C2CCCC2)=C(C2CCCCC2)C=CC=C1 |RG:_R1={C1CCCC1},{C1CCCCC1}|
rgroup 1
Expand All @@ -387,10 +387,10 @@ molecule 05: C1(C2CCCCC2)=C(C2CCCCC2)C=CC=C1 |RG:_R1={C1CCCCC1},{C1CCCCC1}|
fragment 1: C1CCCCC1
fragment 2: C1CCCCC1
===================================================
molecule 06: C1(C2=CC=CC=C2)=C(C2CCCCC2)C=CC=C1 |RG:_R1={C1=CC=CC=C1},{C1CCCCC1}|
molecule 06: C1(C2=CC=CC=C2)=C(C2CCCCC2)C=CC=C1 |RG:_R1={C1CCCCC1},{C1=CC=CC=C1}|
rgroup 1
fragment 1: C1=CC=CC=C1
fragment 2: C1CCCCC1
fragment 1: C1CCCCC1
fragment 2: C1=CC=CC=C1
===================================================
molecule 07: C1(C2CCCC2)=C(C2=CC=CC=C2)C=CC=C1 |RG:_R1={C1CCCC1},{C1=CC=CC=C1}|
rgroup 1
Expand Down
12 changes: 6 additions & 6 deletions core/indigo-core/molecule/molecule_rgroups_composition.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#ifndef __molecule_rgroups_composition__
#define __molecule_rgroups_composition__

#include <map>
#include <memory>

#include "base_cpp/array.h"
#include "base_cpp/multimap.h"
#include "molecule/molecule.h"

namespace indigo
Expand Down Expand Up @@ -240,13 +240,13 @@ namespace indigo

inline Fragment _fragment_coordinates(int rsite, int fragment) const
{
const RedBlackSet<int>& rs = _rsite2rgroup[_rsite2vertex.at(rsite)];

int r = -1;
int f = fragment;
for (int i = rs.begin(); i != rs.end(); i = rs.next(i))
const auto it_end = _rsite2rgroup.upper_bound(_rsite2vertex.at(rsite));

for (auto it = _rsite2rgroup.lower_bound(_rsite2vertex.at(rsite)); it != it_end; it++)
{
r = rs.key(i);
r = it->second;
int size = _rgroup2size[r];
if (f >= size)
{
Expand Down Expand Up @@ -281,7 +281,7 @@ namespace indigo

Array<int> _limits;
Array<int> _rgroup2size;
MultiMap<int, int> _rsite2rgroup;
std::multimap<int, int> _rsite2rgroup;
RedBlackMap<int, int> _rsite2vertex;

mutable std::unique_ptr<Attachments> _ats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* limitations under the License.
***************************************************************************/

#include <map>

#include "base_cpp/array.h"
#include "molecule/base_molecule.h"

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

Array<int> rgroups;
_mol.getAllowedRGroups(vertex, rgroups);
_rsite2rgroup.insert(vertex, rgroups);
for (const auto& rgroup : rgroups)
{
_rsite2rgroup.emplace(vertex, rgroup);
}

int total = 0;
for (int i = 0; i < rgroups.size(); i++)
Expand Down

0 comments on commit d119d96

Please sign in to comment.