Skip to content

Commit

Permalink
Merge pull request #819 from epam/feature/520_std_map_molfile_saver
Browse files Browse the repository at this point in the history
Issue #520: core: replace RedBlackMap  in MolfileSaver class
  • Loading branch information
MysterionRise authored Oct 13, 2022
2 parents 171cbf2 + f87732c commit 6a9e42a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions core/indigo-core/molecule/src/molfile_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "molecule/molfile_saver.h"

#include <ctime>
#include <map>
#include <sstream>

#include "base_cpp/locale_guard.h"
Expand Down Expand Up @@ -2000,7 +2001,7 @@ void MolfileSaver::_writeAttachmentValues2000(Output& output, BaseMolecule& frag
if (fragment.attachmentPointCount() == 0)
return;

RedBlackMap<int, int> orders;
std::map<int, int> orders;
int i;

for (i = 1; i <= fragment.attachmentPointCount(); i++)
Expand All @@ -2010,19 +2011,20 @@ void MolfileSaver::_writeAttachmentValues2000(Output& output, BaseMolecule& frag

while ((idx = fragment.getAttachmentPoint(i, j++)) != -1)
{
int* val;
auto it = orders.find(_atom_mapping[idx]);
int* val = it != orders.end() ? &(it->second) : nullptr;

if ((val = orders.at2(_atom_mapping[idx])) == 0)
orders.insert(_atom_mapping[idx], 1 << (i - 1));
if (!val)
orders.emplace(_atom_mapping[idx], 1 << (i - 1));
else
*val |= 1 << (i - 1);
}
}

output.printf("M APO%3d", orders.size());

for (i = orders.begin(); i < orders.end(); i = orders.next(i))
output.printf(" %3d %3d", orders.key(i), orders.value(i));
for (auto it = orders.begin(); it != orders.end(); it++)
output.printf(" %3d %3d", it->first, it->second);

output.writeCR();
}
Expand Down

0 comments on commit 6a9e42a

Please sign in to comment.