yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #04133
[Branch ~yade-dev/yade/trunk] Rev 2180: 1. Fix bad end iterator on InteractionContainer (since r2092!!). UPDATE your code, this makes sim...
------------------------------------------------------------
revno: 2180
fixes bug(s): https://launchpad.net/bugs/569169
committer: Václav Šmilauer <eudoxos@xxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-04-25 23:52:12 +0200
message:
1. Fix bad end iterator on InteractionContainer (since r2092!!). UPDATE your code, this makes simulations little wrong (some interaction might be processed twice in one step)
modified:
core/InteractionContainer.hpp
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'core/InteractionContainer.hpp'
--- core/InteractionContainer.hpp 2010-03-21 15:25:50 +0000
+++ core/InteractionContainer.hpp 2010-04-25 21:52:12 +0000
@@ -33,11 +33,15 @@
class InteractionContainer: public Serializable{
private :
typedef vector<shared_ptr<Interaction> > ContainerT;
+ // linear array of container interactions
vector<shared_ptr<Interaction> > intrs;
+ // array where vecmap[id1] maps id2 to index in intrs (unsigned int)
vector<map<body_id_t, unsigned int > > vecmap;
+ // might be smaller than intrs.size() to avoid resizing intrs (it can actually only grow)
unsigned int currentSize;
+ // cache local variable to return void pointer after assignment
shared_ptr<Interaction> empty;
- // used only during serialization/deserialization
+ // container filled only during serialization/deserialization
vector<shared_ptr<Interaction> > interaction;
public :
InteractionContainer(): currentSize(0),serializeSorted(false),iterColliderLastRun(-1){
@@ -52,7 +56,8 @@
iterator begin(){return intrs.begin();}
iterator end() {return intrs.end();}
const_iterator begin() const {return intrs.begin();}
- const_iterator end() const {return intrs.end();}
+ /* currentSize tracks real number of interactions, the underlying intrs vector might be larger */
+ const_iterator end() const {return intrs.begin()+currentSize; }
// insertion/deletion
bool insert(body_id_t id1,body_id_t id2);
bool insert(const shared_ptr<Interaction>& i);