ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp (file contents):
Revision 1725 by tim, Wed Nov 10 22:01:06 2004 UTC vs.
Revision 1726 by tim, Wed Nov 10 22:50:03 2004 UTC

# Line 43 | Line 43 | SimInfo::~SimInfo() {
43   }
44  
45   SimInfo::~SimInfo() {
46 <    MemoryUtils::deleteVectorOfPointer(molecules_);
46 >    //MemoryUtils::deleteVectorOfPointer(molecules_);
47      delete sman_;
48  
49   }
50  
51  
52   bool SimInfo::addMolecule(Molecule* mol) {
53 <    std::vector<Molecule*>::iterator i;
53 >    MoleculeIterator i;
54      i = std::find(molecules_.begin(), molecules_.end(), mol);
55      if (i != molecules_.end() ) {
56        molecules_.push_back(mol);
56  
57 +        molecules_.insert(make_pair(mol->getGlobalIndex(), mol));
58 +        
59          nAtoms_ += mol->getNAtoms();
60          nBonds_ += mol->getNBonds();
61          nBends_ += mol->getNBends();
# Line 64 | Line 65 | bool SimInfo::addMolecule(Molecule* mol) {
65          nCutoffGroups_ += mol->getNCutoffGroups();
66          nConstraints_ += mol->getNConstraints();
67  
67        globalIndexToMol_.insert(make_pair(mol->getGlobalIndex(), mol));
68          return true;
69      } else {
70          return false;
# Line 72 | Line 72 | bool SimInfo::removeMolecule(Molecule* mol) {
72   }
73  
74   bool SimInfo::removeMolecule(Molecule* mol) {
75 <    std::vector<Molecule*>::iterator i;
75 >    MoleculeIterator i;
76      i = std::find(molecules_.begin(), molecules_.end(), mol);
77  
78      if (i != molecules_.end() ) {
79 <        molecules_.push_back(mol);
79 >
80          nAtoms_ -= mol->getNAtoms();
81          nBonds_ -= mol->getNBonds();
82          nBends_ -= mol->getNBends();
# Line 86 | Line 86 | bool SimInfo::removeMolecule(Molecule* mol) {
86          nCutoffGroups_ -= mol->getNCutoffGroups();
87          nConstraints_ -= mol->getNConstraints();
88  
89 <        globalIndexToMol_.erase(mol->getGlobalIndex());
89 >        molecules_.erase(mol->getGlobalIndex());
90 >
91 >        delete mol;
92 >        
93          return true;
94      } else {
95          return false;
# Line 96 | Line 99 | Molecule* SimInfo::beginMolecule(std::vector<Molecule*
99   }    
100  
101          
102 < Molecule* SimInfo::beginMolecule(std::vector<Molecule*>::iterator& i) {
102 > Molecule* SimInfo::beginMolecule(MoleculeIterator& i) {
103      i = molecules_.begin();
104      return i == molecules_.end() ? NULL : *i;
105   }    
106  
107 < Molecule* SimInfo::nextMolecule(std::vector<Molecule*>::iterator& i) {
107 > Molecule* SimInfo::nextMolecule(MoleculeIterator& i) {
108      ++i;
109      return i == molecules_.end() ? NULL : *i;    
110   }
# Line 109 | Line 112 | void SimInfo::calcNdf() {
112  
113   void SimInfo::calcNdf() {
114      int ndf_local;
115 <    std::vector<Molecule*>::iterator i;
115 >    MoleculeIterator i;
116      std::vector<StuntDouble*>::iterator j;
117      Molecule* mol;
118      StuntDouble* integrableObject;
# Line 151 | Line 154 | void SimInfo::calcNdfRaw() {
154   void SimInfo::calcNdfRaw() {
155      int ndfRaw_local;
156  
157 <    std::vector<Molecule*>::iterator i;
157 >    MoleculeIterator i;
158      std::vector<StuntDouble*>::iterator j;
159      Molecule* mol;
160      StuntDouble* integrableObject;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines