Changes in src/Atom/atom_bondedparticle.cpp [8cc22f:5aaa43]
- File:
-
- 1 edited
-
src/Atom/atom_bondedparticle.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Atom/atom_bondedparticle.cpp
r8cc22f r5aaa43 52 52 BondedParticle::BondedParticle() 53 53 { 54 ListOfBonds. insert( std::make_pair(0, emptyList));54 ListOfBonds.push_back(BondList()); 55 55 }; 56 56 … … 59 59 BondedParticle::~BondedParticle() 60 60 { 61 for(BondTrajectory_t::iterator iter = ListOfBonds.begin(); !ListOfBonds.empty(); 62 iter = ListOfBonds.begin()) { 63 removeAllBonds(iter->first); 64 ListOfBonds.erase(iter); 65 } 61 removeAllBonds(); 66 62 }; 67 63 … … 224 220 } 225 221 226 /** Removes all bonds in current timestepand their instances, too.222 /** Removes all bonds in all timesteps and their instances, too. 227 223 * 228 224 */ 229 225 void BondedParticle::removeAllBonds() 230 226 { 231 removeAllBonds(WorldTime::getTime()); 227 for (size_t index = 0; index < ListOfBonds.size(); ++index) 228 removeAllBonds(index); 232 229 } 233 230 … … 239 236 { 240 237 //LOG(3,"INFO: Clearing all bonds of " << *this << ": " << ListOfBonds[_step]); 241 BondTrajectory_t::iterator listiter = ListOfBonds.find(_step); 242 if (listiter != ListOfBonds.end()) 243 for (BondList::iterator iter = listiter->second.begin(); 244 !listiter->second.empty(); 245 iter = listiter->second.begin()) { 246 //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds); 247 atom * const Other = (*iter)->GetOtherAtom(this); 248 ASSERT( Other != NULL, 249 "BondedParticle::removeAllBonds() - cannot find bond partner for " 250 +toString(**iter)+"."); 251 Other->UnregisterBond(_step, *iter); 252 UnregisterBond(_step, *iter); 253 } 238 for (BondList::iterator iter = (ListOfBonds[_step]).begin(); 239 !(ListOfBonds[_step]).empty(); 240 iter = (ListOfBonds[_step]).begin()) { 241 //LOG(3,"INFO: Clearing bond (" << *iter << ") " << *(*iter) << " of list " << &ListOfBonds); 242 atom * const Other = (*iter)->GetOtherAtom(this); 243 ASSERT( Other != NULL, 244 "BondedParticle::removeAllBonds() - cannot find bond partner for " 245 +toString(**iter)+"."); 246 Other->UnregisterBond(_step, *iter); 247 UnregisterBond(_step, *iter); 248 } 254 249 } 255 250 … … 265 260 if (Binder->Contains(this)) { 266 261 //LOG(3,"INFO: Registering bond "<< *Binder << " with atom " << *this << " at step " << _step); 267 std::pair< BondTrajectory_t::iterator, bool> inserter = 268 ListOfBonds.insert( std::make_pair( _step, BondList(1, Binder)) ); 269 if (!inserter.second) 270 inserter.first->second.push_back(Binder); 262 if (ListOfBonds.size() <= _step) 263 ListOfBonds.resize(_step+1); 264 ListOfBonds[_step].push_back(Binder); 271 265 if (WorldTime::getTime() == _step) 272 266 NOTIFY(AtomObservable::BondsAdded); … … 296 290 OBSERVE; 297 291 //LOG(0,"INFO: Unregistering bond "<< *Binder << " from list " << &ListOfBonds << " of atom " << *this << " at step " << step); 298 BondTrajectory_t::iterator listiter = ListOfBonds.find(_step);299 if (listiter != ListOfBonds.end()) {300 292 #ifndef NDEBUG 301 BondList::const_iterator iter =302 std::find(listiter->second.begin(), listiter->second.end(), Binder);303 ASSERT( iter != listiter->second.end(),304 "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at "305 +toString(_step));293 BondList::const_iterator iter = 294 std::find(ListOfBonds[_step].begin(), ListOfBonds[_step].end(), Binder); 295 ASSERT( iter != ListOfBonds[_step].end(), 296 "BondedParticle::UnregisterBond() - "+toString(*Binder)+" not contained at " 297 +toString(_step)); 306 298 #endif 307 Binder->removeAtom(this); 308 listiter->second.remove(Binder); 309 if (WorldTime::getTime() == _step) 310 NOTIFY(AtomObservable::BondsRemoved); 311 status = true; 312 } 299 Binder->removeAtom(this); 300 ListOfBonds[_step].remove(Binder); 301 if (WorldTime::getTime() == _step) 302 NOTIFY(AtomObservable::BondsRemoved); 303 status = true; 313 304 } else { 314 305 ELOG(1, *Binder << " does not contain " << *this << "."); … … 337 328 { 338 329 int step = -1; 339 for(BondTrajectory_t::const_iterator listiter = ListOfBonds.begin(); 340 listiter != ListOfBonds.end(); 341 ++listiter) { 342 for (BondList::const_iterator bonditer = listiter->second.begin(); 343 bonditer != listiter->second.end(); 330 int tempstep = 0; 331 for(std::vector<BondList>::const_iterator iter = ListOfBonds.begin(); 332 iter != ListOfBonds.end(); 333 ++iter,++tempstep) { 334 for (BondList::const_iterator bonditer = iter->begin(); 335 bonditer != iter->end(); 344 336 ++bonditer) { 345 337 if ((*bonditer) == Binder) { 346 step = listiter->first;338 step = tempstep; 347 339 break; 348 340 }
Note:
See TracChangeset
for help on using the changeset viewer.
