Changes in src/molecule.cpp [274d45:f8e486]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule.cpp
r274d45 rf8e486 42 42 NoCyclicBonds(0), BondDistance(0.), ActiveFlag(false), IndexNr(-1), 43 43 formula(this,boost::bind(&molecule::calcFormula,this),"formula"), 44 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer( atoms.begin())44 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(begin()) 45 45 { 46 46 … … 48 48 for(int i=MAX_ELEMENTS;i--;) 49 49 ElementsInMolecule[i] = 0; 50 strcpy(name,World::getInstance().getDefaultName() .c_str());50 strcpy(name,World::getInstance().getDefaultName()); 51 51 }; 52 52 … … 146 146 iter--; 147 147 atom* atom = *loc; 148 atomIds.erase( atom->getId() ); 149 atoms.remove( atom ); 148 atoms.erase( loc ); 150 149 atom->removeFromMolecule(); 151 150 return iter; … … 157 156 molecule::const_iterator iter = find(key); 158 157 if (iter != end()){ 159 atomIds.erase( key->getId() ); 160 atoms.remove( key ); 158 atoms.erase( iter++ ); 161 159 key->removeFromMolecule(); 162 160 } … … 166 164 molecule::const_iterator molecule::find ( atom * key ) const 167 165 { 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()); 166 return atoms.find( key ); 174 167 } 175 168 176 169 pair<molecule::iterator,bool> molecule::insert ( atom * const key ) 177 170 { 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 } 171 pair<atomSet::iterator,bool> res = atoms.insert(key); 172 return pair<iterator,bool>(iterator(res.first,this),res.second); 185 173 } 186 174 187 175 bool molecule::containsAtom(atom* key){ 188 return (find(key) != end());176 return atoms.count(key); 189 177 } 190 178 … … 802 790 for (molecule::iterator iter = begin(); !empty(); iter = begin()) 803 791 erase(iter); 804 return empty();805 792 }; 806 793 … … 1023 1010 configuration.MaxPsiDouble /= 2; 1024 1011 configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1; 1025 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {1012 if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2)) { 1026 1013 configuration.ProcPEGamma /= 2; 1027 1014 configuration.ProcPEPsi *= 2; … … 1030 1017 configuration.ProcPEPsi = 1; 1031 1018 } 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 } 1019 configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble; 1040 1020 }; 1041 1021
Note:
See TracChangeset
for help on using the changeset viewer.