Changeset 9d83b6


Ignore:
Timestamp:
Feb 24, 2011, 6:51:32 PM (14 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
a2bdbe
Parents:
c0d9eb
git-author:
Frederik Heber <heber@…> (02/24/11 14:41:13)
git-committer:
Frederik Heber <heber@…> (02/24/11 18:51:32)
Message:

BondedParticleInfo now has vector<BondList>

  • vector<BondList> ListOfBonds is private, getter for (non-)const access.
  • Access everywhere to ListOfBonds replaced by respective getter.
  • Access is as of now always to time step zero.
  • greatest impact is on molecule... files, and ListOfBondsUnitTest.
Location:
src
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FragmentationAction/ConstructBondGraphAction.cpp

    rc0d9eb r9d83b6  
    3232#include "molecule.hpp"
    3333#include "World.hpp"
     34#include "WorldTime.hpp"
    3435
    3536#include <iostream>
     
    6768  // remove every bond from the selected atoms' list
    6869  int AtomCount = 0;
    69   for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection(); AtomRunner != World::getInstance().endAtomSelection(); ++AtomRunner) {
     70  for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
     71      AtomRunner != World::getInstance().endAtomSelection();
     72      ++AtomRunner) {
    7073    AtomCount++;
    71     for(BondList::iterator BondRunner = (AtomRunner->second)->ListOfBonds.begin(); !(AtomRunner->second)->ListOfBonds.empty(); BondRunner = (AtomRunner->second)->ListOfBonds.begin())
     74    BondList& ListOfBonds = (AtomRunner->second)->getListOfBonds();
     75    for(BondList::iterator BondRunner = ListOfBonds.begin();
     76        !ListOfBonds.empty();
     77        BondRunner = ListOfBonds.begin())
    7278      if ((*BondRunner)->leftatom == AtomRunner->second)
    7379        delete((*BondRunner));
     
    8187    DoLog(2) && (Log() << Verbose(2) << "Creating Linked Cell structure ... " << endl);
    8288    LinkedCell::LinkedNodes list;
    83     for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection(); AtomRunner != World::getInstance().endAtomSelection(); ++AtomRunner) {
     89    for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
     90        AtomRunner != World::getInstance().endAtomSelection();
     91        ++AtomRunner) {
    8492      list.push_back(AtomRunner->second);
    8593    }
     
    92100    std::map<TesselPoint *, int> AtomIds;
    93101    int i=0;
    94     for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection(); AtomRunner != World::getInstance().endAtomSelection(); ++AtomRunner) {
     102    for (World::AtomSelectionIterator AtomRunner = World::getInstance().beginAtomSelection();
     103        AtomRunner != World::getInstance().endAtomSelection();
     104        ++AtomRunner) {
    95105      AtomIds.insert(pair<TesselPoint *, int> (AtomRunner->second, i++) );
    96106    }
     
    104114//          Log() << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << " containing " << List->size() << " points." << endl;
    105115          if (List != NULL) {
    106             for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin(); Runner != List->end(); Runner++) {
     116            for (LinkedCell::LinkedNodes::const_iterator Runner = List->begin();
     117                Runner != List->end();
     118                Runner++) {
    107119              Walker = dynamic_cast<atom*>(*Runner);
    108120              ASSERT(Walker,"Tesselpoint that was not an atom retrieved from LinkedNode");
  • src/Actions/FragmentationAction/SubgraphDissectionAction.cpp

    rc0d9eb r9d83b6  
    7878    vector <atom *> allatoms = World::getInstance().getAllAtoms();
    7979    for(vector<atom *>::iterator AtomRunner = allatoms.begin(); AtomRunner != allatoms.end(); ++AtomRunner) {
    80       BondCount += (*AtomRunner)->ListOfBonds.size();
    81 //      for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     80      const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     81      BondCount += ListOfBonds.size();
     82//      for(BondList::iterator BondRunner = ListOfBonds.begin();
     83//          !ListOfBonds.empty();
     84//          BondRunner = ListOfBonds.begin()) {
    8285//        delete(*BondRunner);
     86//      }
    8387      mol->AddAtom(*AtomRunner);
    8488    }
  • src/Actions/MoleculeAction/CopyAction.cpp

    rc0d9eb r9d83b6  
    5959  MoleculeCopyState *state = assert_cast<MoleculeCopyState*>(_state.get());
    6060
    61   for (molecule::iterator AtomRunner = state->copy->begin(); !state->copy->empty(); AtomRunner = state->copy->begin()) {
    62     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     61  for (molecule::iterator AtomRunner = state->copy->begin();
     62      !state->copy->empty();
     63      AtomRunner = state->copy->begin()) {
     64    BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     65    for(BondList::iterator BondRunner = ListOfBonds.begin();
     66        !ListOfBonds.empty();
     67        BondRunner = ListOfBonds.begin()) {
    6368      delete(*BondRunner);
     69    }
    6470    atom *Walker = *AtomRunner;
    6571    state->copy->erase(AtomRunner);
  • src/Parser/PdbParser.cpp

    rc0d9eb r9d83b6  
    325325 * Writes the neighbor information of one atom to the provided stream.
    326326 *
     327 * Note that ListOfBonds of WorldTime::CurrentTime is used.
     328 *
    327329 * \param *file  where to write neighbor information to
    328330 * \param MaxnumberOfNeighbors of neighbors
     
    331333void PdbParser::writeNeighbors(ostream* file, int MaxnumberOfNeighbors, atom* currentAtom) {
    332334  int MaxNo = MaxnumberOfNeighbors;
    333   if (!currentAtom->ListOfBonds.empty()) {
    334     for(BondList::iterator currentBond = currentAtom->ListOfBonds.begin(); currentBond != currentAtom->ListOfBonds.end(); ++currentBond) {
     335  const BondList & ListOfBonds = currentAtom->getListOfBonds();
     336  if (!ListOfBonds.empty()) {
     337    for(BondList::const_iterator currentBond = ListOfBonds.begin(); currentBond != ListOfBonds.end(); ++currentBond) {
    335338      if (MaxNo >= MaxnumberOfNeighbors) {
    336339        *file << "CONECT";
  • src/Parser/TremoloParser.cpp

    rc0d9eb r9d83b6  
    2626#include "TremoloParser.hpp"
    2727#include "World.hpp"
     28#include "WorldTime.hpp"
    2829#include "atom.hpp"
    2930#include "bond.hpp"
     
    258259 * Writes the neighbor information of one atom to the provided stream.
    259260 *
     261 * Note that ListOfBonds of WorldTime::CurrentTime is used.
     262 *
    260263 * \param stream where to write neighbor information to
    261264 * \param number of neighbors
     
    263266 */
    264267void TremoloParser::writeNeighbors(ostream* file, int numberOfNeighbors, atom* currentAtom) {
    265   BondList::iterator currentBond = currentAtom->ListOfBonds.begin();
     268  const BondList& ListOfBonds = currentAtom->getListOfBonds();
     269  BondList::const_iterator currentBond = ListOfBonds.begin();
    266270  for (int i = 0; i < numberOfNeighbors; i++) {
    267     *file << (currentBond != currentAtom->ListOfBonds.end()
     271    *file << (currentBond != ListOfBonds.end()
    268272        ? (*currentBond)->GetOtherAtom(currentAtom)->getId()+1 : 0) << "\t";
    269     if (currentBond != currentAtom->ListOfBonds.end())
     273    if (currentBond != ListOfBonds.end())
    270274      ++currentBond;
    271275  }
  • src/WorldTime.hpp

    rc0d9eb r9d83b6  
    2222  //!> own unit test should be friend to access private variables.
    2323  friend class WorldTimeTest;
     24  //!> ListOfBonds test has to be friend to access private variables.
     25  friend class ListOfBondsTest;
    2426
    2527  //!> World is friend to access setTime (alone!)
  • src/analysis_bonds.cpp

    rc0d9eb r9d83b6  
    4343  int AtomCount = 0;
    4444  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    45     const int count = (*iter)->ListOfBonds.size();
     45    const BondList& ListOfBonds = (*iter)->getListOfBonds();
     46    const int count = ListOfBonds.size();
    4647    if (Max < count)
    4748      Max = count;
     
    7273  int AtomNo = 0;
    7374  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    74     if ((*iter)->getType() == type1)
    75       for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
     75    if ((*iter)->getType() == type1) {
     76      const BondList& ListOfBonds = (*iter)->getListOfBonds();
     77      for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     78          BondRunner != ListOfBonds.end();
     79          BondRunner++)
    7680        if ((*BondRunner)->GetOtherAtom((*iter))->getType() == type2) {
    7781          const double distance = (*BondRunner)->GetDistanceSquared();
     
    8387          AtomNo++;
    8488        }
     89    }
    8590  }
    8691  if (Max < 0) {
     
    161166              InterfaceFlag = (InterfaceElement == NULL);
    162167              Interface2Flag = (Interface2Element == NULL);
    163               for (BondList::const_iterator BondRunner = (*Runner)->ListOfBonds.begin(); BondRunner != (*Runner)->ListOfBonds.end(); BondRunner++) {
     168              const BondList& ListOfBonds = (*Runner)->getListOfBonds();
     169              for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     170                  BondRunner != ListOfBonds.end();
     171                  BondRunner++) {
    164172                atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Runner);
    165173                // if hydrogen, check angle to be greater(!) than 30 degrees
     
    187195              if (InterfaceFlag && Interface2Flag && OtherHydrogenFlag) {
    188196                // on this element (Walker) we check for bond to hydrogen, i.e. part of water molecule
    189                 for (BondList::const_iterator BondRunner = (*Walker)->ListOfBonds.begin(); BondRunner != (*Walker)->ListOfBonds.end(); BondRunner++) {
     197                const BondList& ListOfBonds = (*Walker)->getListOfBonds();
     198                for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     199                    BondRunner != ListOfBonds.end();
     200                    BondRunner++) {
    190201                  atom * const OtherAtom = (*BondRunner)->GetOtherAtom(*Walker);
    191202                  if (OtherAtom->getType()->getAtomicNumber() == 1) {
     
    223234      atom * theAtom = *Walker;
    224235      if ((theAtom->getType() == first) || (theAtom->getType() == second)) {  // first element matches
    225         for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     236        const BondList& ListOfBonds = theAtom->getListOfBonds();
     237        for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     238            BondRunner != ListOfBonds.end();
     239            BondRunner++) {
    226240          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
    227241          if (((OtherAtom->getType() == first) || (OtherAtom->getType() == second)) && (theAtom->nr < OtherAtom->nr)) {
     
    261275        for (int i=0;i<2;i++)
    262276          MatchFlag[i] = false;
    263         for (BondList::const_iterator BondRunner = theAtom->ListOfBonds.begin(); BondRunner != theAtom->ListOfBonds.end(); BondRunner++) {
     277        const BondList& ListOfBonds = theAtom->getListOfBonds();
     278        for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     279            BondRunner != ListOfBonds.end();
     280            BondRunner++) {
    264281          atom * const OtherAtom = (*BondRunner)->GetOtherAtom(theAtom);
    265282          for (int i=0;i<2;i++)
  • src/analysis_correlation.cpp

    rc0d9eb r9d83b6  
    6666      ++atomiter) {
    6767    // go through all bonds
    68     for (BondList::const_iterator bonditer = (*atomiter)->ListOfBonds.begin();
    69         bonditer != (*atomiter)->ListOfBonds.end();
     68    const BondList& ListOfBonds = (*atomiter)->getListOfBonds();
     69    for (BondList::const_iterator bonditer = ListOfBonds.begin();
     70        bonditer != ListOfBonds.end();
    7071        ++bonditer) {
    7172      const atom * Otheratom = (*bonditer)->GetOtherAtom(*atomiter);
  • src/atom.cpp

    rc0d9eb r9d83b6  
    7272{
    7373  removeFromMolecule();
    74   for(BondList::iterator iter=ListOfBonds.begin(); iter!=ListOfBonds.end();){
    75     // deleting the bond will invalidate the iterator !!!
    76     bond *bond =*(iter++);
    77     delete(bond);
    78   }
    7974};
    8075
     
    294289  if (ComponentNr != NULL)
    295290    delete[](ComponentNr);
     291  const BondList& ListOfBonds = getListOfBonds();
    296292  ComponentNr = new int[ListOfBonds.size()+1];
    297293  for (int i=ListOfBonds.size()+1;i--;)
  • src/atom_bondedparticle.cpp

    rc0d9eb r9d83b6  
    2727#include "CodePatterns/Log.hpp"
    2828#include "CodePatterns/Verbose.hpp"
     29#include "WorldTime.hpp"
    2930
    3031/** Constructor of class BondedParticle.
     
    3233BondedParticle::BondedParticle()
    3334{
     35  ListOfBonds.push_back(BondList());
    3436};
    3537
     
    3840BondedParticle::~BondedParticle()
    3941{
    40   BondList::const_iterator Runner;
    41   while (!ListOfBonds.empty()) {
    42     Runner = ListOfBonds.begin();
    43     removewithoutcheck(*Runner);
     42  BondList::iterator Runner;
     43  for (std::vector<BondList>::iterator iter = ListOfBonds.begin();
     44      !ListOfBonds.empty();
     45      iter = ListOfBonds.begin()) {
     46    while (!(*iter).empty()) {
     47      Runner = (*iter).begin();
     48      removewithoutcheck(*Runner);
     49    }
     50    ListOfBonds.erase(iter);
    4451  }
    4552};
     
    5865void BondedParticle::OutputBondOfAtom() const
    5966{
     67  const BondList& ListOfBonds = getListOfBonds();
    6068  DoLog(4) && (Log() << Verbose(4) << "Atom " << getName() << "/" << nr << " with " << ListOfBonds.size() << " bonds: " << endl);
    6169  int TotalDegree = 0;
     
    7280void BondedParticle::OutputAdjacency(ofstream * const AdjacencyFile) const
    7381{
     82  const BondList& ListOfBonds = getListOfBonds();
    7483  *AdjacencyFile << nr << "\t";
    7584  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
     
    8493void BondedParticle::OutputBonds(ofstream * const BondFile) const
    8594{
     95  const BondList& ListOfBonds = getListOfBonds();
    8696  for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner))
    8797    if (nr < (*Runner)->GetOtherAtom(this)->nr)
     
    113123  if (Binder != NULL) {
    114124    if (Binder->Contains(this)) {
     125      BondList& ListOfBonds = getListOfBonds();
    115126      ListOfBonds.push_back(Binder);
    116127      status = true;
     
    125136
    126137/** Removes a given bond from atom::ListOfBonds.
     138 * @param _step time step to access
    127139 * \param *Binder bond to remove
    128140 */
     
    132144  if (Binder != NULL) {
    133145    if (Binder->Contains(this)) {
     146      BondList& ListOfBonds = getListOfBonds();
    134147      ListOfBonds.remove(Binder);
    135148      status = true;
     
    148161void BondedParticle::UnregisterAllBond()
    149162{
     163  BondList& ListOfBonds = getListOfBonds();
    150164  ListOfBonds.clear();
    151165};
     
    165179  //Log() << Verbose(3) << "Walker " << *this << ": " << (int)this->type->NoValenceOrbitals << " > " << NoBonds << "?" << endl;
    166180  if ((int)(getType()->getNoValenceOrbitals()) > NoBonds) { // we have a mismatch, check all bonding partners for mismatch
     181    const BondList& ListOfBonds = getListOfBonds();
    167182    for (BondList::const_iterator Runner = ListOfBonds.begin(); Runner != ListOfBonds.end(); (++Runner)) {
    168183      OtherWalker = (*Runner)->GetOtherAtom(this);
     
    170185      //Log() << Verbose(3) << "OtherWalker " << *OtherWalker << ": " << (int)OtherWalker->type->NoValenceOrbitals << " > " << OtherNoBonds << "?" << endl;
    171186      if ((int)(OtherWalker->getType()->getNoValenceOrbitals()) > OtherNoBonds) { // check if possible candidate
    172         if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherWalker->ListOfBonds.size())) { // pick the one with fewer number of bonds first
     187        const BondList& OtherListOfBonds = OtherWalker->getListOfBonds();
     188        if ((CandidateBond == NULL) || (ListOfBonds.size() > OtherListOfBonds.size())) { // pick the one with fewer number of bonds first
    173189          CandidateBond = (*Runner);
    174190          //Log() << Verbose(3) << "New candidate is " << *CandidateBond << "." << endl;
     
    194210{
    195211  int NoBonds = 0;
     212  const BondList& ListOfBonds = getListOfBonds();
    196213  for (BondList::const_iterator Runner = ListOfBonds.begin();
    197214      Runner != ListOfBonds.end();
     
    209226  bool status = false;
    210227
    211   for (BondList::iterator runner = ListOfBonds.begin(); runner != ListOfBonds.end(); runner++) {
     228  const BondList& ListOfBonds = getListOfBonds();
     229  for (BondList::const_iterator runner = ListOfBonds.begin(); runner != ListOfBonds.end(); runner++) {
    212230    status = status || ((*runner)->Contains(BondPartner));
    213231  }
  • src/atom_bondedparticleinfo.cpp

    rc0d9eb r9d83b6  
    2020#include "CodePatterns/MemDebug.hpp"
    2121
     22#include "CodePatterns/Assert.hpp"
     23
     24#include "WorldTime.hpp"
     25
    2226#include "atom_bondedparticleinfo.hpp"
    2327
     
    2731  AdaptiveOrder(0),
    2832  MaxOrder(false)
    29 {};
     33{}
    3034
    3135/** Destructor of class BondedParticleInfo.
    3236 */
    3337BondedParticleInfo::~BondedParticleInfo()
     38{}
     39
     40const BondList& BondedParticleInfo::getListOfBonds() const
    3441{
    35 };
     42  ASSERT(WorldTime::getTime() < ListOfBonds.size(),
     43      "BondedParticleInfo::getBondsAtStep() - Access out of range: "
     44      +toString(WorldTime::getTime())
     45      +" not in [0,"+toString(ListOfBonds.size())+").");
     46  return ListOfBonds[WorldTime::getTime()];
     47}
    3648
     49BondList& BondedParticleInfo::getListOfBonds()
     50{
     51  const unsigned int size = ListOfBonds.size();
     52  ASSERT(WorldTime::getTime() <= size,
     53      "BondedParticleInfo::getBondsAtStep() - Access out of range: "
     54      +toString(WorldTime::getTime())
     55      +" not in [0,"+toString(size)+"].");
     56  if (WorldTime::getTime() == size) {
     57    ListOfBonds.push_back(BondList());
     58  }
     59  return ListOfBonds[WorldTime::getTime()];
     60}
     61
     62const BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step) const
     63{
     64  ASSERT(_step < ListOfBonds.size(),
     65      "BondedParticleInfo::getBondsAtStep() - Access out of range: "
     66      +toString(WorldTime::getTime())
     67      +" not in [0,"+toString(ListOfBonds.size())+").");
     68  return ListOfBonds[_step];
     69}
     70
     71BondList& BondedParticleInfo::getListOfBondsAtStep(unsigned int _step)
     72{
     73  const unsigned int size = ListOfBonds.size();
     74  ASSERT(_step <= size,
     75      "BondedParticleInfo::getBondsAtStep() - Access out of range: "
     76      +toString(_step)
     77      +" not in [0,"+toString(size)+"].");
     78  if (_step == size) {
     79    ListOfBonds.push_back(BondList());
     80  }
     81  return ListOfBonds[_step];
     82}
  • src/atom_bondedparticleinfo.hpp

    rc0d9eb r9d83b6  
    2424
    2525class bond;
     26class BondedParticle;
    2627
    2728#define BondList list<bond *>
     
    3031
    3132class BondedParticleInfo {
     33  friend class BondedParticle;
    3234public:
    3335  unsigned char AdaptiveOrder;  //!< current present bond order at site (0 means "not set")
    3436  bool MaxOrder;  //!< whether this atom as a root in fragmentation still creates more fragments on higher orders or not
    35   BondList ListOfBonds; //!< list of all bonds
    3637
    3738  BondedParticleInfo();
    3839  virtual ~BondedParticleInfo();
    3940
     41  /** Const accessor to ListOfBonds of WorldTime::CurrentTime.
     42   *
     43   * @return ListOfBonds[WorldTime::CurrentTime]
     44   */
     45  const BondList& getListOfBonds() const;
     46  /** Accessor to ListOfBonds of WorldTime::CurrentTime.
     47   *
     48   * Note, new empty BondList is returned if array entry at upper boundary is
     49   * accessed. Beyond std will issue exception due to out-of-range access.
     50   *
     51   * @return ListOfBonds[WorldTime::CurrentTime]
     52   */
     53  BondList& getListOfBonds();
     54
     55  /** Const Accessor ListOfBonds of any present time step.
     56   *
     57   * @param _step time step to access
     58   * @return ListOfBonds[_step].
     59   */
     60  const BondList& getListOfBondsAtStep(unsigned int _step) const;
     61  /** Accessor ListOfBonds of any present time step.
     62   *
     63   * Note, new empty BondList is returned if array entry at upper boundary is
     64   * accessed. Beyond std will issue exception due to out-of-range access.
     65   *
     66   * @param _step time step to access
     67   * @return ListOfBonds[_step].
     68   */
     69  BondList& getListOfBondsAtStep(unsigned int _step);
     70
    4071private:
     72  std::vector<BondList> ListOfBonds; //!< list of all bonds
    4173
    4274};
  • src/boundary.cpp

    rc0d9eb r9d83b6  
    818818  const int FillerCount = filler->getAtomCount();
    819819  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
    820   for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
    821     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     820  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
     821    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     822    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     823        BondRunner != ListOfBonds.end();
     824        ++BondRunner) {
    822825      if ((*BondRunner)->leftatom == *AtomRunner)
    823826        DoLog(2) && (Log() << Verbose(2) << "  " << *(*BondRunner) << endl);
     827    }
     828  }
    824829
    825830  atom * CopyAtoms[FillerCount];
     
    912917        }
    913918        // go through all bonds and add as well
    914         for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
    915           for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     919        for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
     920          const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     921          for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     922              BondRunner != ListOfBonds.end();
     923              ++BondRunner)
    916924            if ((*BondRunner)->leftatom == *AtomRunner) {
    917925              Binder = (*BondRunner);
     
    921929              }
    922930            }
     931        }
    923932      }
    924933  for (MoleculeList::iterator ListRunner = List->ListOfMolecules.begin(); ListRunner != List->ListOfMolecules.end(); ListRunner++) {
     
    10841093  //const int FillerCount = filler->getAtomCount();
    10851094  DoLog(2) && (Log() << Verbose(2) << "INFO: Filler molecule has the following bonds:" << endl);
    1086   for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner)
    1087     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     1095  for(molecule::iterator AtomRunner = filler->begin(); AtomRunner != filler->end(); ++AtomRunner) {
     1096    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     1097    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     1098        BondRunner != ListOfBonds.end();
     1099        ++BondRunner)
    10881100      if ((*BondRunner)->leftatom == *AtomRunner)
    10891101        DoLog(2) && (Log() << Verbose(2) << "  " << *(*BondRunner) << endl);
     1102  }
    10901103
    10911104  // calculate filler grid in [0,1]^3
  • src/config.cpp

    rc0d9eb r9d83b6  
    965965  int MaxNeighbours = 0;
    966966  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    967     const int count = (*iter)->ListOfBonds.size();
     967    const int count = (*iter)->getListOfBonds().size();
    968968    if (MaxNeighbours < count)
    969969      MaxNeighbours = count;
     
    979979    *output << static_cast<double>((*iter)->getType()->getValence()) << "\t";
    980980    *output << (*iter)->getType()->getSymbol() << "\t";
    981     for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     981    const BondList& ListOfBonds = (*iter)->getListOfBonds();
     982    for (BondList::const_iterator runner = ListOfBonds.begin();
     983        runner != ListOfBonds.end();
     984        runner++) {
    982985      *output << (*runner)->GetOtherAtom(*iter)->nr << "\t";
    983     for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
     986    }
     987    for(int i = ListOfBonds.size(); i < MaxNeighbours; i++)
    984988      *output << "-\t";
    985989    *output << endl;
     
    10171021  for (MoleculeList::const_iterator MolWalker = MolList->ListOfMolecules.begin(); MolWalker != MolList->ListOfMolecules.end(); MolWalker++) {
    10181022    for (molecule::const_iterator iter = (*MolWalker)->begin(); iter != (*MolWalker)->end(); ++iter) {
    1019       const int count = (*iter)->ListOfBonds.size();
     1023      const int count = (*iter)->getListOfBonds().size();
    10201024      if (MaxNeighbours < count)
    10211025        MaxNeighbours = count;
     
    10511055        *output << (double)(*iter)->getType()->getValence() << "\t";
    10521056        *output << (*iter)->getType()->getSymbol() << "\t";
    1053         for (BondList::iterator runner = (*iter)->ListOfBonds.begin(); runner != (*iter)->ListOfBonds.end(); runner++)
     1057        const BondList& ListOfBonds = (*iter)->getListOfBonds();
     1058        for (BondList::const_iterator runner = ListOfBonds.begin();
     1059            runner != ListOfBonds.end();
     1060            runner++) {
    10541061          *output << LocalNotoGlobalNoMap[ (*runner)->GetOtherAtom((*iter))->getId() ] << "\t";
    1055         for(int i=(*iter)->ListOfBonds.size(); i < MaxNeighbours; i++)
     1062        }
     1063        for(int i = ListOfBonds.size(); i < MaxNeighbours; i++)
    10561064          *output << "-\t";
    10571065        *output << endl;
  • src/molecule.cpp

    rc0d9eb r9d83b6  
    2626#include <gsl/gsl_heapsort.h>
    2727
    28 #include "World.hpp"
    2928#include "atom.hpp"
    3029#include "bond.hpp"
     30#include "Box.hpp"
     31#include "CodePatterns/enumeration.hpp"
     32#include "CodePatterns/Log.hpp"
    3133#include "config.hpp"
    3234#include "element.hpp"
     35#include "Exceptions/LinearDependenceException.hpp"
    3336#include "graph.hpp"
    3437#include "Helpers/helpers.hpp"
    3538#include "LinearAlgebra/leastsquaremin.hpp"
     39#include "LinearAlgebra/Plane.hpp"
     40#include "LinearAlgebra/RealSpaceMatrix.hpp"
     41#include "LinearAlgebra/Vector.hpp"
    3642#include "linkedcell.hpp"
    3743#include "lists.hpp"
    38 #include "CodePatterns/Log.hpp"
    3944#include "molecule.hpp"
    40 
    4145#include "periodentafel.hpp"
    4246#include "tesselation.hpp"
    43 #include "LinearAlgebra/Vector.hpp"
    44 #include "LinearAlgebra/RealSpaceMatrix.hpp"
    4547#include "World.hpp"
    46 #include "Box.hpp"
    47 #include "LinearAlgebra/Plane.hpp"
    48 #include "Exceptions/LinearDependenceException.hpp"
    49 
    50 #include "CodePatterns/enumeration.hpp"
     48#include "WorldTime.hpp"
     49
    5150
    5251/************************************* Functions for class molecule *********************************/
     
    383382      break;
    384383    case 2:
    385       // determine two other bonds (warning if there are more than two other) plus valence sanity check
    386       for (BondList::const_iterator Runner = TopOrigin->ListOfBonds.begin(); Runner != TopOrigin->ListOfBonds.end(); (++Runner)) {
    387         if ((*Runner) != TopBond) {
    388           if (FirstBond == NULL) {
    389             FirstBond = (*Runner);
    390             FirstOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    391           } else if (SecondBond == NULL) {
    392             SecondBond = (*Runner);
    393             SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
    394           } else {
    395             DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->getName());
     384      {
     385        // determine two other bonds (warning if there are more than two other) plus valence sanity check
     386        const BondList& ListOfBonds = TopOrigin->getListOfBonds();
     387        for (BondList::const_iterator Runner = ListOfBonds.begin();
     388            Runner != ListOfBonds.end();
     389            ++Runner) {
     390          if ((*Runner) != TopBond) {
     391            if (FirstBond == NULL) {
     392              FirstBond = (*Runner);
     393              FirstOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
     394            } else if (SecondBond == NULL) {
     395              SecondBond = (*Runner);
     396              SecondOtherAtom = (*Runner)->GetOtherAtom(TopOrigin);
     397            } else {
     398              DoeLog(2) && (eLog()<< Verbose(2) << "Detected more than four bonds for atom " << TopOrigin->getName());
     399            }
    396400          }
    397401        }
     
    642646
    643647  // copy all bonds
    644   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    645     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     648  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     649    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     650    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     651        BondRunner != ListOfBonds.end();
     652        ++BondRunner)
    646653      if ((*BondRunner)->leftatom == *AtomRunner) {
    647654        bond *Binder = (*BondRunner);
     
    660667        NewBond->Type = Binder->Type;
    661668      }
     669  }
    662670  // correct fathers
    663671  for_each(atoms.begin(),atoms.end(),mem_fun(&atom::CorrectFather));
     
    749757  //DoeLog(1) && (eLog()<< Verbose(1) << "molecule::RemoveBond: Function not implemented yet." << endl);
    750758  BondList::const_iterator ForeRunner;
    751   while (!BondPartner->ListOfBonds.empty()) {
    752     ForeRunner = BondPartner->ListOfBonds.begin();
     759  BondList& ListOfBonds = BondPartner->getListOfBonds();
     760  while (!ListOfBonds.empty()) {
     761    ForeRunner = ListOfBonds.begin();
    753762    RemoveBond(*ForeRunner);
    754763  }
  • src/molecule_fragmentation.cpp

    rc0d9eb r9d83b6  
    5656  // get maximum bond degree
    5757  for (molecule::const_iterator iter = begin(); iter != end(); ++iter) {
    58     c = ((*iter)->ListOfBonds.size() > c) ? (*iter)->ListOfBonds.size() : c;
     58    const BondList& ListOfBonds = (*iter)->getListOfBonds();
     59    c = (ListOfBonds.size() > c) ? ListOfBonds.size() : c;
    5960  }
    6061  FragmentCount = NoNonHydrogen*(1 << (c*order));
     
    670671        atomiter != (*iter)->end();
    671672        ++atomiter) {
    672       for (BondList::iterator bonditer = (*atomiter)->ListOfBonds.begin();
    673           bonditer != (*atomiter)->ListOfBonds.end();
     673      const BondList& ListOfBonds = (*atomiter)->getListOfBonds();
     674      for (BondList::const_iterator bonditer = ListOfBonds.begin();
     675          bonditer != ListOfBonds.end();
    674676          ++bonditer) {
    675677        (*bonditer)->BondDegree = 1;
     
    10091011    if (SonList[FatherOfRunner->nr] != NULL)  {  // check if this, our father, is present in list
    10101012      // create all bonds
    1011       for (BondList::const_iterator BondRunner = FatherOfRunner->ListOfBonds.begin(); BondRunner != FatherOfRunner->ListOfBonds.end(); (++BondRunner)) {
     1013      const BondList& ListOfBonds = FatherOfRunner->getListOfBonds();
     1014      for (BondList::const_iterator BondRunner = ListOfBonds.begin();
     1015          BondRunner != ListOfBonds.end();
     1016          ++BondRunner) {
    10121017        OtherFather = (*BondRunner)->GetOtherAtom(FatherOfRunner);
    10131018//        Log() << Verbose(2) << "Father " << *FatherOfRunner << " of son " << *SonList[FatherOfRunner->nr] << " is bound to " << *OtherFather;
     
    14161421      // go through all its bonds
    14171422      DoLog(1) && (Log() << Verbose(1) << "Going through all bonds of Walker." << endl);
    1418       for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1423      const BondList& ListOfBonds = Walker->getListOfBonds();
     1424      for (BondList::const_iterator Runner = ListOfBonds.begin();
     1425          Runner != ListOfBonds.end();
     1426          ++Runner) {
    14191427        OtherWalker = (*Runner)->GetOtherAtom(Walker);
    14201428        if ((RestrictedKeySet.find(OtherWalker->nr) != RestrictedKeySet.end())
     
    18111819    // scan all bonds
    18121820    flag = false;
    1813     for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner)
    1814       for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); (!flag) && (BondRunner != (*AtomRunner)->ListOfBonds.end()); ++BondRunner) {
     1821    for(molecule::iterator AtomRunner = begin(); (!flag) && (AtomRunner != end()); ++AtomRunner) {
     1822      const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     1823      for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     1824          (!flag) && (BondRunner != ListOfBonds.end());
     1825          ++BondRunner) {
    18151826        Binder = (*BondRunner);
    18161827        for (int i=NDIM;i--;) {
     
    18321843        }
    18331844      }
     1845    }
    18341846    //if (flag) {
    18351847    if (0) {
     
    18531865        ColorList[Walker->nr] = black;    // mark as explored
    18541866        *Walker += Translationvector; // translate
    1855         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1867        const BondList& ListOfBonds = Walker->getListOfBonds();
     1868        for (BondList::const_iterator Runner = ListOfBonds.begin();
     1869            Runner != ListOfBonds.end();
     1870            ++Runner) {
    18561871          if ((*Runner) != Binder) {
    18571872            OtherWalker = (*Runner)->GetOtherAtom(Walker);
  • src/molecule_geometry.cpp

    rc0d9eb r9d83b6  
    384384        Testvector = inversematrix * (*iter)->getPosition();
    385385        Translationvector.Zero();
    386         for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     386        const BondList& ListOfBonds = (*iter)->getListOfBonds();
     387        for (BondList::const_iterator Runner = ListOfBonds.begin();
     388            Runner != ListOfBonds.end();
     389            ++Runner) {
    387390         if ((*iter)->nr < (*Runner)->GetOtherAtom((*iter))->nr) // otherwise we shift one to, the other fro and gain nothing
    388391            for (int j=0;j<NDIM;j++) {
     
    404407#ifdef ADDHYDROGEN
    405408        // now also change all hydrogens
    406         for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     409        for (BondList::const_iterator Runner = ListOfBonds.begin();
     410            Runner != ListOfBonds.end();
     411            ++Runner) {
    407412          if ((*Runner)->GetOtherAtom((*iter))->getType()->getAtomicNumber() == 1) {
    408413            Testvector = inversematrix * (*Runner)->GetOtherAtom((*iter))->getPosition();
  • src/molecule_graph.cpp

    rc0d9eb r9d83b6  
    3535#include "molecule.hpp"
    3636#include "World.hpp"
     37#include "WorldTime.hpp"
    3738#include "Box.hpp"
    3839
     
    149150  DoLog(0) && (Log() << Verbose(0) << "Begin of CreateAdjacencyList." << endl);
    150151  // remove every bond from the list
    151   for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    152     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     152  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     153    BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     154    for(BondList::iterator BondRunner = ListOfBonds.begin();
     155        !ListOfBonds.empty();
     156        BondRunner = ListOfBonds.begin())
    153157      if ((*BondRunner)->leftatom == *AtomRunner)
    154158        delete((*BondRunner));
     159  }
    155160  BondCount = 0;
    156161
     
    239244bool molecule::hasBondStructure() const
    240245{
    241   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    242     if (!(*AtomRunner)->ListOfBonds.empty())
     246  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     247    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     248    if (!ListOfBonds.empty())
    243249      return true;
     250  }
    244251  return false;
    245252}
     
    251258{
    252259  unsigned int counter = 0;
    253   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    254     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     260  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     261    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     262    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     263        BondRunner != ListOfBonds.end();
     264        ++BondRunner)
    255265      if ((*BondRunner)->leftatom == *AtomRunner)
    256266        counter++;
     267  }
    257268  return counter;
    258269}
     
    264275{
    265276  DoLog(1) && (Log() << Verbose(1) << endl << "From contents of bond chain list:");
    266   for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner)
    267     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     277  for(molecule::const_iterator AtomRunner = molecule::begin(); AtomRunner != molecule::end(); ++AtomRunner) {
     278    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     279    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     280        BondRunner != ListOfBonds.end();
     281        ++BondRunner)
    268282      if ((*BondRunner)->leftatom == *AtomRunner) {
    269283        DoLog(0) && (Log() << Verbose(0) << *(*BondRunner) << "\t" << endl);
    270284      }
     285  }
    271286  DoLog(0) && (Log() << Verbose(0) << endl);
    272287}
     
    315330  MoleculeLeafClass *Subgraphs = NULL;
    316331  std::deque<bond *> *BackEdgeStack = NULL;
    317   for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    318     if ((!(*AtomRunner)->ListOfBonds.empty()) && ((*(*AtomRunner)->ListOfBonds.begin())->Type == Undetermined)) {
     332  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     333    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     334    if ((!ListOfBonds.empty()) && ((*ListOfBonds.begin())->Type == Undetermined)) {
    319335      DoLog(0) && (Log() << Verbose(0) << "No Depth-First-Search analysis performed so far, calling ..." << endl);
    320336      Subgraphs = DepthFirstSearchAnalysis(BackEdgeStack);
     
    327343      break;
    328344    }
    329   for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    330     for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     345  }
     346  for(molecule::iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     347    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     348    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     349        BondRunner != ListOfBonds.end();
     350        ++BondRunner)
    331351      if ((*BondRunner)->leftatom == *AtomRunner)
    332352        if ((*BondRunner)->Cyclic)
    333353          NoCyclicBonds++;
     354  }
    334355  delete (BackEdgeStack);
    335356  return NoCyclicBonds;
     
    637658{
    638659  NoCyclicBonds = 0;
    639   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    640     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     660  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     661    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     662    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     663        BondRunner != ListOfBonds.end();
     664        ++BondRunner)
    641665      if ((*BondRunner)->leftatom == *AtomRunner)
    642666        if ((*BondRunner)->rightatom->LowpointNr == (*BondRunner)->leftatom->LowpointNr) { // cyclic ??
     
    644668          NoCyclicBonds++;
    645669        }
     670  }
    646671}
    647672;
     
    662687void molecule::OutputGraphInfoPerBond() const
    663688{
    664   bond *Binder = NULL;
    665689  DoLog(1) && (Log() << Verbose(1) << "Final graph info for each bond is:" << endl);
    666   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    667     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     690  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     691    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     692    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     693        BondRunner != ListOfBonds.end();
     694        ++BondRunner)
    668695      if ((*BondRunner)->leftatom == *AtomRunner) {
    669         Binder = *BondRunner;
     696        const bond *Binder = *BondRunner;
    670697        if (DoLog(2)) {
    671698          ostream &out = (Log() << Verbose(2));
     
    681708          DoLog(3) && (Log() << Verbose(3) << "Lowpoint at each side are equal: CYCLIC!" << endl);
    682709      }
     710  }
    683711}
    684712;
     
    762790    BFS.BFSStack->pop_front();
    763791    DoLog(2) && (Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *BFS.Root << "." << endl);
    764     for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     792    const BondList& ListOfBonds = Walker->getListOfBonds();
     793    for (BondList::const_iterator Runner = ListOfBonds.begin();
     794        Runner != ListOfBonds.end();
     795        ++Runner) {
    765796      if ((*Runner) != BackEdge) { // only walk along DFS spanning tree (otherwise we always find SP of one being backedge Binder)
    766797        OtherAtom = (*Runner)->GetOtherAtom(Walker);
     
    895926    BFS.BFSStack->pop_front();
    896927    //Log() << Verbose(2) << "Current Walker is " << *Walker << ", we look for SP to Root " << *Root << "." << endl;
    897     for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     928    const BondList& ListOfBonds = Walker->getListOfBonds();
     929    for (BondList::const_iterator Runner = ListOfBonds.begin();
     930        Runner != ListOfBonds.end();
     931        ++Runner) {
    898932      // "removed (*Runner) != BackEdge) || " from next if, is u
    899       if ((Walker->ListOfBonds.size() == 1)) { // only walk along DFS spanning tree (otherwise we always find SP of 1 being backedge Binder), but terminal hydrogens may be connected via backedge, hence extra check
     933      if ((ListOfBonds.size() == 1)) { // only walk along DFS spanning tree (otherwise we always find SP of 1 being backedge Binder), but terminal hydrogens may be connected via backedge, hence extra check
    900934        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    901935        //Log() << Verbose(2) << "Current OtherAtom is: " << OtherAtom->Name << " for bond " << *Binder << "." << endl;
     
    10171051  size_t i = 0;
    10181052  if (vertex != NULL) {
    1019     for (; i < vertex->ListOfBonds.size(); i++) {
     1053    const BondList& ListOfBonds = vertex->getListOfBonds();
     1054    for (; i < ListOfBonds.size(); i++) {
    10201055      if (vertex->ComponentNr[i] == -1) { // check if not yet used
    10211056        vertex->ComponentNr[i] = nr;
     
    10241059        break; // breaking here will not cause error!
    10251060    }
    1026     if (i == vertex->ListOfBonds.size()) {
     1061    if (i == ListOfBonds.size()) {
    10271062      DoeLog(0) && (eLog()<< Verbose(0) << "Error: All Component entries are already occupied!" << endl);
    10281063      performCriticalExit();
     
    10411076bond * molecule::FindNextUnused(atom *vertex) const
    10421077{
    1043   for (BondList::const_iterator Runner = vertex->ListOfBonds.begin(); Runner != vertex->ListOfBonds.end(); (++Runner))
     1078  const BondList& ListOfBonds = vertex->getListOfBonds();
     1079  for (BondList::const_iterator Runner = ListOfBonds.begin();
     1080      Runner != ListOfBonds.end();
     1081      ++Runner)
    10441082    if ((*Runner)->IsUsed() == white)
    10451083      return ((*Runner));
     
    10531091void molecule::ResetAllBondsToUnused() const
    10541092{
    1055   for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner)
    1056     for(BondList::const_iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); BondRunner != (*AtomRunner)->ListOfBonds.end(); ++BondRunner)
     1093  for(molecule::const_iterator AtomRunner = begin(); AtomRunner != end(); ++AtomRunner) {
     1094    const BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     1095    for(BondList::const_iterator BondRunner = ListOfBonds.begin();
     1096        BondRunner != ListOfBonds.end();
     1097        ++BondRunner)
    10571098      if ((*BondRunner)->leftatom == *AtomRunner)
    10581099        (*BondRunner)->ResetUsed();
     1100  }
    10591101}
    10601102;
     
    11681210
    11691211  //Log() << Verbose(2) << "Walker is " << *Walker << ", bond partners: ";
    1170   if (CurrentBondsOfAtom == Walker->ListOfBonds.size()) {
    1171     for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1212  const BondList& ListOfBonds = Walker->getListOfBonds();
     1213  if (CurrentBondsOfAtom == ListOfBonds.size()) {
     1214    for (BondList::const_iterator Runner = ListOfBonds.begin();
     1215        Runner != ListOfBonds.end();
     1216        ++Runner) {
    11721217      id = (*Runner)->GetOtherAtom(Walker)->nr;
    11731218      j = 0;
     
    11851230    //Log() << Verbose(0) << endl;
    11861231  } else {
    1187     DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << Walker->ListOfBonds.size() << "." << endl);
     1232    DoLog(0) && (Log() << Verbose(0) << "Number of bonds for Atom " << *Walker << " does not match, parsed " << CurrentBondsOfAtom << " against " << ListOfBonds.size() << "." << endl);
    11881233    status = false;
    11891234  }
     
    12711316  do { // go through all bonds and push local ones
    12721317    Walker = ListOfLocalAtoms[Binder->leftatom->nr]; // get one atom in the reference molecule
    1273     if (Walker != NULL) // if this Walker exists in the subgraph ...
    1274       for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1318    if (Walker != NULL) { // if this Walker exists in the subgraph ...
     1319      const BondList& ListOfBonds = Walker->getListOfBonds();
     1320      for (BondList::const_iterator Runner = ListOfBonds.begin();
     1321          Runner != ListOfBonds.end();
     1322          ++Runner) {
    12751323        OtherAtom = (*Runner)->GetOtherAtom(Walker);
    12761324        if (OtherAtom == ListOfLocalAtoms[(*Runner)->rightatom->nr]) { // found the bond
     
    12801328        }
    12811329      }
     1330    }
    12821331    ASSERT(!ReferenceStack->empty(), "molecule::PickLocalBackEdges() - ReferenceStack is empty!");
    12831332    Binder = ReferenceStack->front(); // loop the stack for next item
     
    14231472    Walker = BFS.BFSStack->front(); // pop oldest added
    14241473    BFS.BFSStack->pop_front();
    1425     DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << Walker->ListOfBonds.size() << " bonds." << endl);
    1426     for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1474    const BondList& ListOfBonds = Walker->getListOfBonds();
     1475    DoLog(1) && (Log() << Verbose(1) << "Current Walker is: " << Walker->getName() << ", and has " << ListOfBonds.size() << " bonds." << endl);
     1476    for (BondList::const_iterator Runner = ListOfBonds.begin();
     1477        Runner != ListOfBonds.end();
     1478        ++Runner) {
    14271479      if ((*Runner) != NULL) { // don't look at bond equal NULL
    14281480        Binder = (*Runner);
     
    14961548        status = false;
    14971549      } else {
    1498         for (BondList::const_iterator Runner = (*iter)->ListOfBonds.begin(); Runner != (*iter)->ListOfBonds.end(); (++Runner)) {
     1550        const BondList& ListOfBonds = (*iter)->getListOfBonds();
     1551        for (BondList::const_iterator Runner = ListOfBonds.begin();
     1552            Runner != ListOfBonds.end();
     1553            ++Runner) {
    14991554          OtherAtom = (*Runner)->GetOtherAtom((*iter));
    15001555          if (ParentList[OtherAtom->nr] != NULL) { // if otheratom is also a father of an atom on this molecule, create the bond
     
    15341589
    15351590/** For a given keyset \a *Fragment, checks whether it is connected in the current molecule.
    1536  * \param *out output stream for debugging
    15371591 * \param *Fragment Keyset of fragment's vertices
    15381592 * \return true - connected, false - disconnected
     
    15581612      for (KeySet::iterator runners = Fragment->begin(); runners != Fragment->end(); runners++) {
    15591613        Walker2 = FindAtom(*runners);
    1560         for (BondList::const_iterator Runner = Walker->ListOfBonds.begin(); Runner != Walker->ListOfBonds.end(); (++Runner)) {
     1614        const BondList& ListOfBonds = Walker->getListOfBonds();
     1615        for (BondList::const_iterator Runner = ListOfBonds.begin();
     1616            Runner != ListOfBonds.end();
     1617            ++Runner) {
    15611618          if ((*Runner)->GetOtherAtom(Walker) == Walker2) {
    15621619            BondStatus = true;
  • src/moleculelist.cpp

    rc0d9eb r9d83b6  
    363363    // 2. take every hydrogen that is a saturated one
    364364    for (molecule::const_iterator iter = (*ListRunner)->begin(); iter != (*ListRunner)->end(); ++iter) {
    365       //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
     365      //Log() << Verbose(1) << "(*iter): " << *(*iter) << " with first bond " << *((*iter)->getListOfBonds().begin()) << "." << endl;
    366366      if (((*iter)->getType()->getAtomicNumber() == 1) && (((*iter)->father == NULL)
    367367          || ((*iter)->father->getType()->getAtomicNumber() != 1))) { // if it's a hydrogen
    368368        for (molecule::const_iterator runner = (*ListRunner)->begin(); runner != (*ListRunner)->end(); ++runner) {
    369           //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->ListOfBonds.begin()) << "." << endl;
     369          //Log() << Verbose(2) << "Runner: " << *(*runner) << " with first bond " << *((*iter)->getListOfBonds().begin()) << "." << endl;
    370370          // 3. take every other hydrogen that is the not the first and not bound to same bonding partner
    371           Binder = *((*runner)->ListOfBonds.begin());
     371          Binder = *((*runner)->getListOfBonds().begin());
    372372          if (((*runner)->getType()->getAtomicNumber() == 1) && ((*runner)->nr > (*iter)->nr) && (Binder->GetOtherAtom((*runner)) != Binder->GetOtherAtom((*iter)))) { // (hydrogens have only one bonding partner!)
    373373            // 4. evaluate the morse potential for each matrix component and add up
     
    805805    DoLog(1) && (Log() << Verbose(1) << "Creating adjacency list for subgraph " << Leaf << "." << endl);
    806806    // remove every bond from the list
    807     for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner)
    808       for(BondList::iterator BondRunner = (*AtomRunner)->ListOfBonds.begin(); !(*AtomRunner)->ListOfBonds.empty(); BondRunner = (*AtomRunner)->ListOfBonds.begin())
     807    for(molecule::iterator AtomRunner = Leaf->begin(); AtomRunner != Leaf->end(); ++AtomRunner) {
     808      BondList& ListOfBonds = (*AtomRunner)->getListOfBonds();
     809      for(BondList::iterator BondRunner = ListOfBonds.begin();
     810          !ListOfBonds.empty();
     811          BondRunner = ListOfBonds.begin())
    809812        if ((*BondRunner)->leftatom == *AtomRunner)
    810813          delete((*BondRunner));
     814    }
     815
    811816
    812817    for(molecule::const_iterator iter = Leaf->begin(); iter != Leaf->end(); ++iter) {
    813818      Father = (*iter)->GetTrueFather();
    814819      AtomNo = Father->nr; // global id of the current walker
    815       for (BondList::const_iterator Runner = Father->ListOfBonds.begin(); Runner != Father->ListOfBonds.end(); (++Runner)) {
     820      const BondList& ListOfBonds = Father->getListOfBonds();
     821      for (BondList::const_iterator Runner = ListOfBonds.begin();
     822          Runner != ListOfBonds.end();
     823          ++Runner) {
    816824        OtherWalker = ListOfLocalAtoms[(*Runner)->GetOtherAtom((*iter)->GetTrueFather())->nr]; // local copy of current bond partner of walker
    817825        if (OtherWalker != NULL) {
  • src/unittests/ListOfBondsUnitTest.cpp

    rc0d9eb r9d83b6  
    126126
    127127  // check that bond is present in both atoms
    128   bond *TestBond1 = *(atom1->ListOfBonds.begin());
     128  BondList::const_iterator bonditer;
     129  bonditer = atom1->getListOfBonds().begin();
     130  bond *TestBond1 = *bonditer;
    129131  CPPUNIT_ASSERT_EQUAL( TestBond1, Binder );
    130   bond *TestBond2 = *(atom2->ListOfBonds.begin());
     132  bonditer = atom2->getListOfBonds().begin();
     133  bond *TestBond2 = *bonditer;
    131134  CPPUNIT_ASSERT_EQUAL( TestBond2, Binder );
    132135};
     
    153156
    154157  // check if removed from atoms
    155   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
    156   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom2->ListOfBonds.size() );
     158  {
     159    const BondList& ListOfBonds = atom1->getListOfBonds();
     160    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     161  }
     162  {
     163    const BondList& ListOfBonds = atom2->getListOfBonds();
     164    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     165  }
    157166
    158167  // check if removed from molecule
     
    185194
    186195  // check that all are present
    187   CPPUNIT_ASSERT_EQUAL( (size_t) 2, atom1->ListOfBonds.size() );
    188   CPPUNIT_ASSERT_EQUAL( (size_t) 2, atom2->ListOfBonds.size() );
    189   CPPUNIT_ASSERT_EQUAL( (size_t) 2, atom3->ListOfBonds.size() );
     196  {
     197    const BondList& ListOfBonds = atom1->getListOfBonds();
     198    CPPUNIT_ASSERT_EQUAL( (size_t) 2, ListOfBonds.size() );
     199  }
     200  {
     201    const BondList& ListOfBonds = atom2->getListOfBonds();
     202    CPPUNIT_ASSERT_EQUAL( (size_t) 2, ListOfBonds.size() );
     203  }
     204  {
     205    const BondList& ListOfBonds = atom3->getListOfBonds();
     206    CPPUNIT_ASSERT_EQUAL( (size_t) 2, ListOfBonds.size() );
     207  }
    190208
    191209  // remove bond
     
    193211
    194212  // check if removed from atoms
    195   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
    196   CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
    197   CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom3->ListOfBonds.size() );
     213  {
     214    const BondList& ListOfBonds = atom1->getListOfBonds();
     215    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     216  }
     217  {
     218    const BondList& ListOfBonds = atom2->getListOfBonds();
     219    CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() );
     220  }
     221  {
     222    const BondList& ListOfBonds = atom3->getListOfBonds();
     223    CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() );
     224  }
    198225
    199226  // check if removed from molecule
     
    223250
    224251  // check if removed from atoms
    225   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
    226   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom2->ListOfBonds.size() );
     252  {
     253    const BondList& ListOfBonds = atom1->getListOfBonds();
     254    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     255  }
     256  {
     257    const BondList& ListOfBonds = atom2->getListOfBonds();
     258    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     259  }
    227260
    228261  // check if removed from molecule
     
    251284
    252285  // check bond if removed from other atom
    253   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
     286  {
     287    const BondList& ListOfBonds = atom1->getListOfBonds();
     288    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     289  }
    254290
    255291  // check if removed from molecule
     
    278314  CPPUNIT_ASSERT( Binder != NULL );
    279315
    280   CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom1->ListOfBonds.size() );
    281   CPPUNIT_ASSERT_EQUAL( (size_t) 1, atom2->ListOfBonds.size() );
     316  {
     317    const BondList& ListOfBonds = atom1->getListOfBonds();
     318    CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() );
     319  }
     320  {
     321    const BondList& ListOfBonds = atom2->getListOfBonds();
     322    CPPUNIT_ASSERT_EQUAL( (size_t) 1, ListOfBonds.size() );
     323  }
    282324
    283325  CPPUNIT_ASSERT_EQUAL( true, TestMolecule->hasBondStructure() );
     
    287329
    288330  // check bond if removed from other atom
    289   CPPUNIT_ASSERT_EQUAL( (size_t) 0, atom1->ListOfBonds.size() );
     331  {
     332    const BondList& ListOfBonds = atom1->getListOfBonds();
     333    CPPUNIT_ASSERT_EQUAL( (size_t) 0, ListOfBonds.size() );
     334  }
    290335
    291336  // check if removed from molecule
Note: See TracChangeset for help on using the changeset viewer.