Changes in src/molecule.cpp [274d45:43dad6]
- File:
-
- 1 edited
-
src/molecule.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r274d45 r43dad6 4 4 * 5 5 */ 6 7 #include "Helpers/MemDebug.hpp"8 6 9 7 #include <cstring> … … 37 35 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero. 38 36 */ 39 molecule::molecule(const periodentafel * const teil) : 40 Observable("molecule"),41 elemente(teil), MDSteps(0), BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0),42 NoCyclicBonds(0), BondDistance(0.),ActiveFlag(false), IndexNr(-1),43 formula(this,boost::bind(&molecule::calcFormula,this) ,"formula"),44 AtomCount(this,boost::bind(&molecule::doCountAtoms,this) ,"AtomCount"), last_atom(0), InternalPointer(atoms.begin())37 molecule::molecule(const periodentafel * const teil) : elemente(teil), 38 MDSteps(0), 39 BondCount(0), ElementCount(0), NoNonHydrogen(0), NoNonBonds(0), NoCyclicBonds(0), BondDistance(0.), 40 ActiveFlag(false), IndexNr(-1), 41 formula(this,boost::bind(&molecule::calcFormula,this)), 42 AtomCount(this,boost::bind(&molecule::doCountAtoms,this)), last_atom(0), InternalPointer(begin()) 45 43 { 46 44 … … 145 143 molecule::const_iterator iter = loc; 146 144 iter--; 147 atom* atom = *loc; 148 atomIds.erase( atom->getId() ); 149 atoms.remove( atom ); 150 atom->removeFromMolecule(); 145 atoms.erase( loc ); 151 146 return iter; 152 147 } 153 148 154 molecule::const_iterator molecule::erase( atom * key )149 molecule::const_iterator molecule::erase( atom *& key ) 155 150 { 156 151 cout << "trying to erase atom" << endl; 157 152 molecule::const_iterator iter = find(key); 158 153 if (iter != end()){ 159 atomIds.erase( key->getId() ); 160 atoms.remove( key ); 161 key->removeFromMolecule(); 154 // remove this position and step forward (post-increment) 155 atoms.erase( iter++ ); 162 156 } 163 157 return iter; 164 158 } 165 159 166 molecule::const_iterator molecule::find ( atom * key ) const 167 { 168 molecule::const_iterator iter; 169 for (molecule::const_iterator Runner = begin(); Runner != end(); ++Runner) { 170 if (*Runner == key) 171 return molecule::const_iterator(Runner); 172 } 173 return molecule::const_iterator(atoms.end()); 160 molecule::const_iterator molecule::find ( atom *& key ) const 161 { 162 return atoms.find( key ); 174 163 } 175 164 176 165 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 177 166 { 178 pair<atomIdSet::iterator,bool> res = atomIds.insert(key->getId()); 179 if (res.second) { // push atom if went well 180 atoms.push_back(key); 181 return pair<iterator,bool>(molecule::iterator(--end()),res.second); 182 } else { 183 return pair<iterator,bool>(molecule::iterator(end()),res.second); 184 } 185 } 186 187 bool molecule::containsAtom(atom* key){ 188 return (find(key) != end()); 167 pair<atomSet::iterator,bool> res = atoms.insert(key); 168 return pair<iterator,bool>(iterator(res.first,this),res.second); 189 169 } 190 170 … … 212 192 } 213 193 insert(pointer); 214 pointer->setMolecule(this);215 194 } 216 195 return true; … … 678 657 bond * molecule::AddBond(atom *atom1, atom *atom2, int degree) 679 658 { 680 OBSERVE;681 659 bond *Binder = NULL; 682 660 … … 802 780 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 803 781 erase(iter); 804 return empty();805 782 }; 806 783 … … 881 858 ElementNo[i] = current++; 882 859 } 883 ActOnAllAtoms( &atom::OutputArrayIndexed, output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL );860 ActOnAllAtoms( &atom::OutputArrayIndexed, (ostream * const) output, (const int *)ElementNo, (int *)AtomNo, (const char *) NULL ); 884 861 return true; 885 862 } … … 1023 1000 configuration.MaxPsiDouble /= 2; 1024 1001 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1; 1025 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {1002 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2)) { 1026 1003 configuration.ProcPEGamma /= 2; 1027 1004 configuration.ProcPEPsi *= 2; … … 1030 1007 configuration.ProcPEPsi = 1; 1031 1008 } 1032 cout << configuration.PsiMaxNoDown << ">" << configuration.PsiMaxNoUp << endl; 1033 if (configuration.PsiMaxNoDown > configuration.PsiMaxNoUp) { 1034 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoDown; 1035 cout << configuration.PsiMaxNoDown << " " << configuration.InitMaxMinStopStep << endl; 1036 } else { 1037 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.PsiMaxNoUp; 1038 cout << configuration.PsiMaxNoUp << " " << configuration.InitMaxMinStopStep << endl; 1039 } 1009 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble; 1040 1010 }; 1041 1011
Note:
See TracChangeset
for help on using the changeset viewer.
