Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #520: core: replace RedBlackMap in MoleculeRGroupsComposition class #810

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/indigo-core/molecule/molecule_rgroups_composition.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace indigo

bool operator<(const Fragment& other) const
{
return rgroup < other.rgroup || fragment < other.fragment;
return std::pair<int, int>{rgroup, fragment} < std::pair<int, int>{other.rgroup, other.fragment};
}
};

Expand Down Expand Up @@ -294,4 +294,4 @@ namespace indigo
#ifdef _WIN32
#endif

#endif
#endif
12 changes: 7 additions & 5 deletions core/indigo-core/molecule/src/molecule_rgroups_composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
***************************************************************************/

#include <map>

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

Expand Down Expand Up @@ -131,20 +133,20 @@ MoleculeIter::SourceRGroups::SourceRGroups(const MoleculeIter& m)
Array<int> fs;
m._at.dump(fs);
MultiMap<int, int> rgroup2fragment;
RedBlackMap<Fragment, int> fragment2count;
std::map<Fragment, int> fragment2count;
for (auto i = 0; i < fs.size(); i++)
{
auto x = m._parent._fragment_coordinates(i, fs[i]);
if (rgroup2fragment.find(x.rgroup, x.fragment))
{
int count = fragment2count.at(x);
fragment2count.remove(x);
fragment2count.insert(x, count + 1);
fragment2count.erase(x);
fragment2count.emplace(x, count + 1);
}
else
{
rgroup2fragment.insert(x.rgroup, x.fragment);
fragment2count.insert(x, 1);
fragment2count.emplace(x, 1);
}
}

Expand Down Expand Up @@ -240,4 +242,4 @@ const Array<int>* AttachmentIter::operator*() const
void AttachmentIter::dump(Array<int>& other) const
{
other.copy(_fragments);
}
}