Changeset 972706


Ignore:
Timestamp:
Oct 7, 2009, 1:18:59 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
70b7aa
Parents:
0cd3b2
Message:

molecule::CountElements() changed to use SetIndexedArrayForEachAtomTo(), molecule::OutputXYZ() fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/molecule.cpp

    r0cd3b2 r972706  
    822822  time_t now;
    823823
    824   now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
    825   walker = start;
    826   while (walker->next != end) { // go through every atom and count
    827     walker = walker->next;
    828     AtomNo++;
    829   }
    830824  if (out != NULL) {
    831     *out << AtomNo << "\n\tCreated by molecuilder on " << ctime(&now);
     825    now = time((time_t *)NULL);   // Get the system time and put it into 'now' as 'calender time'
     826    *out << AtomCount << "\n\tCreated by molecuilder on " << ctime(&now);
    832827    ActOnAllAtoms( &atom::OutputXYZLine, out );
    833828    return true;
     
    876871void molecule::CountElements()
    877872{
    878   int i = 0;
    879   for(i=MAX_ELEMENTS;i--;)
     873  for(int i=MAX_ELEMENTS;i--;)
    880874    ElementsInMolecule[i] = 0;
    881875  ElementCount = 0;
    882876
    883   atom *walker = start;
    884   while (walker->next != end) {
    885     walker = walker->next;
    886     ElementsInMolecule[walker->type->Z]++;
    887     i++;
    888   }
    889   for(i=MAX_ELEMENTS;i--;)
     877  SetIndexedArrayForEachAtomTo ( ElementsInMolecule, &element::Z, &Increment, 1);
     878
     879  for(int i=MAX_ELEMENTS;i--;)
    890880    ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);
    891881};
    892 
    893882
    894883
Note: See TracChangeset for help on using the changeset viewer.