45#include "brains/PairList.hpp"
57 for (std::set<std::pair<int, int>>::iterator i = pairSet_.begin();
58 i != pairSet_.end(); ++i) {
59 pairList_.push_back(i->first + 1);
60 pairList_.push_back(i->second + 1);
65 return pairList_.empty() ? NULL : &(pairList_[0]);
75 std::set<std::pair<int, int>>::iterator iter =
76 pairSet_.find(std::make_pair(i, j));
78 if (iter == pairSet_.end()) {
79 pairSet_.insert(std::make_pair(i, j));
84 void PairList::addPairs(std::set<int>& set1, std::set<int>& set2) {
85 for (std::set<int>::iterator iter1 = set1.begin(); iter1 != set1.end();
87 for (std::set<int>::iterator iter2 = set2.begin(); iter2 != set2.end();
94 template<
typename IterType1,
typename IterType2>
95 void PairList::addPairs(IterType1 iter1_first, IterType1 iter1_last,
96 IterType2 iter2_first, IterType2 iter2_last) {
97 for (IterType1 iter1 = iter1_first; iter1 != iter1_last; ++iter1) {
98 for (IterType2 iter2 = iter2_first; iter2 != iter2_last; ++iter2) {
111 std::set<std::pair<int, int>>::iterator iter =
112 pairSet_.find(std::make_pair(i, j));
114 if (iter != pairSet_.end()) {
115 pairSet_.erase(iter);
120 void PairList::removePairs(std::set<int>& set1, std::set<int>& set2) {
121 for (std::set<int>::iterator iter1 = set1.begin(); iter1 != set1.end();
123 for (std::set<int>::iterator iter2 = set2.begin(); iter2 != set2.end();
130 template<
typename IterType1,
typename IterType2>
131 void PairList::removePairs(IterType1 iter1_first, IterType1 iter1_last,
132 IterType2 iter2_first, IterType2 iter2_last) {
133 for (IterType1 iter1 = iter1_first; iter1 != iter1_last; ++iter1) {
134 for (IterType2 iter2 = iter2_first; iter2 != iter2_last; ++iter2) {
147 std::set<std::pair<int, int>>::iterator iter =
148 pairSet_.find(std::make_pair(i, j));
149 return iter == pairSet_.end() ? false :
true;
154 std::ostream& operator<<(std::ostream& o,
PairList& e) {
155 std::set<std::pair<int, int>>::iterator i;
161 for (i = e.pairSet_.begin(); i != e.pairSet_.end(); ++i) {
162 o <<
"pairList[" << index <<
"] i, j: " << (*i).first <<
" - "
163 << (*i).second <<
"\n";
PairList class maintains a general purpose list of atom pairs using the global indices of the atoms.
int * getPairList()
Returns the pairs in a plain array.
bool hasPair(int i, int j)
Checks whether pair (i, j) is in this PairList class.
void addPair(int i, int j)
Adds a pair into this PairList class.
void removePair(int i, int j)
Remove a pair from PairList class.
int getSize()
Returns the number of pairs in the list.
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.