@@ -132,40 +132,28 @@ MoleculeIter::SourceRGroups::SourceRGroups(const MoleculeIter& m)
132
132
{
133
133
Array<int > fs;
134
134
m._at .dump (fs);
135
- MultiMap <int , int > rgroup2fragment;
135
+ std::multimap <int , int > rgroup2fragment;
136
136
std::map<Fragment, int > fragment2count;
137
137
for (auto i = 0 ; i < fs.size (); i++)
138
138
{
139
139
auto x = m._parent ._fragment_coordinates (i, fs[i]);
140
- if (rgroup2fragment.find (x.rgroup , x.fragment ))
141
- {
142
- int count = fragment2count.at (x);
143
- fragment2count.erase (x);
144
- fragment2count.emplace (x, count + 1 );
145
- }
146
- else
147
- {
148
- rgroup2fragment.insert (x.rgroup , x.fragment );
149
- fragment2count.emplace (x, 1 );
150
- }
140
+ rgroup2fragment.emplace (x.rgroup , x.fragment );
141
+ fragment2count.emplace (x, 1 );
151
142
}
152
143
153
- const RedBlackSet<int >& rgroups = rgroup2fragment.keys ();
154
- for (auto i = rgroups.begin (); i != rgroups.end (); i = rgroups.next (i))
144
+ for (auto it = rgroup2fragment.begin (); it != rgroup2fragment.end (); it = rgroup2fragment.upper_bound (it->first ))
155
145
{
156
- auto r = rgroups.key (i);
157
146
RGroup& rgroup = _rgroups.push ();
158
- RGroup& source = m._parent ._rgroups .getRGroup (r );
147
+ RGroup& source = m._parent ._rgroups .getRGroup (it-> first );
159
148
160
- const RedBlackSet< int >& fs_r = rgroup2fragment[r] ;
161
- for (auto j = fs_r. begin ( ); j != fs_r. end (); j = fs_r. next (j) )
149
+ const auto it_end = rgroup2fragment. upper_bound (it-> first ) ;
150
+ for (auto it_fs_r = rgroup2fragment. lower_bound (it-> first ); it_fs_r != it_end; it_fs_r++ )
162
151
{
163
- auto f = fs_r.key (j);
164
- for (auto k = 0 ; k < fragment2count.at ({r, f}); k++)
152
+ for (auto k = 0 ; k < fragment2count.at ({it->first , it_fs_r->second }); k++)
165
153
{
166
154
int fr_idx = rgroup.fragments .add (new Molecule ());
167
155
BaseMolecule* fragment = rgroup.fragments .at (fr_idx);
168
- fragment->clone (*source.fragments [f ], nullptr , nullptr );
156
+ fragment->clone (*source.fragments [it_fs_r-> second ], nullptr , nullptr );
169
157
fragment->removeAttachmentPoints ();
170
158
}
171
159
}
0 commit comments