Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule.cpp

    r274d45 r43dad6  
    44 *
    55 */
    6 
    7 #include "Helpers/MemDebug.hpp"
    86
    97#include <cstring>
     
    3735 * Initialises molecule list with correctly referenced start and end, and sets molecule::last_atom to zero.
    3836 */
    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())
     37molecule::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())
    4543{
    4644
     
    145143  molecule::const_iterator iter = loc;
    146144  iter--;
    147   atom* atom = *loc;
    148   atomIds.erase( atom->getId() );
    149   atoms.remove( atom );
    150   atom->removeFromMolecule();
     145  atoms.erase( loc );
    151146  return iter;
    152147}
    153148
    154 molecule::const_iterator molecule::erase( atom * key )
     149molecule::const_iterator molecule::erase( atom *& key )
    155150{
    156151  cout << "trying to erase atom" << endl;
    157152  molecule::const_iterator iter = find(key);
    158153  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++ );
    162156  }
    163157  return iter;
    164158}
    165159
    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());
     160molecule::const_iterator molecule::find ( atom *& key ) const
     161{
     162  return atoms.find( key );
    174163}
    175164
    176165pair<molecule::iterator,bool> molecule::insert ( atom * const key )
    177166{
    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);
    189169}
    190170
     
    212192    }
    213193    insert(pointer);
    214     pointer->setMolecule(this);
    215194  }
    216195  return true;
     
    678657bond * molecule::AddBond(atom *atom1, atom *atom2, int degree)
    679658{
    680   OBSERVE;
    681659  bond *Binder = NULL;
    682660
     
    802780  for (molecule::iterator iter = begin(); !empty(); iter = begin())
    803781      erase(iter);
    804   return empty();
    805782};
    806783
     
    881858        ElementNo[i] = current++;
    882859    }
    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 );
    884861    return true;
    885862  }
     
    10231000  configuration.MaxPsiDouble /= 2;
    10241001  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)) {
    10261003    configuration.ProcPEGamma /= 2;
    10271004    configuration.ProcPEPsi *= 2;
     
    10301007    configuration.ProcPEPsi = 1;
    10311008  }
    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;
    10401010};
    10411011
Note: See TracChangeset for help on using the changeset viewer.