Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/molecule.cpp

    rf8e486 r274d45  
    4242  NoCyclicBonds(0), BondDistance(0.),  ActiveFlag(false), IndexNr(-1),
    4343  formula(this,boost::bind(&molecule::calcFormula,this),"formula"),
    44   AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(begin())
     44  AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0),  InternalPointer(atoms.begin())
    4545{
    4646
     
    4848  for(int i=MAX_ELEMENTS;i--;)
    4949    ElementsInMolecule[i] = 0;
    50   strcpy(name,World::getInstance().getDefaultName());
     50  strcpy(name,World::getInstance().getDefaultName().c_str());
    5151};
    5252
     
    146146  iter--;
    147147  atom* atom = *loc;
    148   atoms.erase( loc );
     148  atomIds.erase( atom->getId() );
     149  atoms.remove( atom );
    149150  atom->removeFromMolecule();
    150151  return iter;
     
    156157  molecule::const_iterator iter = find(key);
    157158  if (iter != end()){
    158     atoms.erase( iter++ );
     159    atomIds.erase( key->getId() );
     160    atoms.remove( key );
    159161    key->removeFromMolecule();
    160162  }
     
    164166molecule::const_iterator molecule::find ( atom * key ) const
    165167{
    166   return atoms.find( key );
     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());
    167174}
    168175
    169176pair<molecule::iterator,bool> molecule::insert ( atom * const key )
    170177{
    171   pair<atomSet::iterator,bool> res = atoms.insert(key);
    172   return pair<iterator,bool>(iterator(res.first,this),res.second);
     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  }
    173185}
    174186
    175187bool molecule::containsAtom(atom* key){
    176   return atoms.count(key);
     188  return (find(key) != end());
    177189}
    178190
     
    790802  for (molecule::iterator iter = begin(); !empty(); iter = begin())
    791803      erase(iter);
     804  return empty();
    792805};
    793806
     
    10101023  configuration.MaxPsiDouble /= 2;
    10111024  configuration.PsiType = (configuration.PsiMaxNoDown == configuration.PsiMaxNoUp) ? 0 : 1;
    1012   if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2)) {
     1025  if ((configuration.PsiType == 1) && (configuration.ProcPEPsi < 2) && ((configuration.PsiMaxNoDown != 1) || (configuration.PsiMaxNoUp != 0))) {
    10131026    configuration.ProcPEGamma /= 2;
    10141027    configuration.ProcPEPsi *= 2;
     
    10171030    configuration.ProcPEPsi = 1;
    10181031  }
    1019   configuration.InitMaxMinStopStep = configuration.MaxMinStopStep = configuration.MaxPsiDouble;
     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  }
    10201040};
    10211041
Note: See TracChangeset for help on using the changeset viewer.