mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-04 21:54:27 +08:00
* run clang-tidy with readability-braces-around-statements clang-format the results clean up all the parts that clang-tidy-8 broke * fix problem on windows
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
#include <algorithm>
|
|
#include <utility>
|
|
#include "StereoGroup.h"
|
|
|
|
namespace RDKit {
|
|
|
|
StereoGroup::StereoGroup(StereoGroupType grouptype, std::vector<Atom *> &&atoms)
|
|
: d_grouptype(grouptype), d_atoms(atoms) {}
|
|
StereoGroup::StereoGroup(StereoGroupType grouptype,
|
|
const std::vector<Atom *> &atoms)
|
|
: d_grouptype(grouptype), d_atoms(std::move(atoms)) {}
|
|
|
|
StereoGroupType StereoGroup::getGroupType() const { return d_grouptype; }
|
|
|
|
const std::vector<Atom *> &StereoGroup::getAtoms() const { return d_atoms; }
|
|
|
|
void removeGroupsWithAtom(const Atom *atom, std::vector<StereoGroup> &groups) {
|
|
auto containsAtom = [atom](const StereoGroup &group) {
|
|
return std::find(group.getAtoms().cbegin(), group.getAtoms().cend(),
|
|
atom) != group.getAtoms().cend();
|
|
};
|
|
groups.erase(std::remove_if(groups.begin(), groups.end(), containsAtom),
|
|
groups.end());
|
|
}
|
|
|
|
void removeGroupsWithAtoms(const std::vector<Atom *> &atoms,
|
|
std::vector<StereoGroup> &groups) {
|
|
auto containsAnyAtom = [atoms](const StereoGroup &group) {
|
|
for (auto atom : atoms) {
|
|
if (std::find(group.getAtoms().cbegin(), group.getAtoms().cend(), atom) !=
|
|
group.getAtoms().cend()) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
groups.erase(std::remove_if(groups.begin(), groups.end(), containsAnyAtom),
|
|
groups.end());
|
|
}
|
|
|
|
} // namespace RDKit
|