Hi, I think as you rightly observed, iterators are nothing but temporary objects. If you need them twice, create them twice. The likes of NaryUnion and NaryInter are special in that constructing them is expensive and hence they feature a reset method. For the other iterators, there would be not benefit in having reset methods (as you observed correctly) as reiterating is the same efficiencywise as reseting them (actually, redoing is cheaper as one does need to track pointers etc).
Cheers Christian -- Christian Schulte, www.ict.kth.se/~cschulte/ > -----Original Message----- > From: [email protected] [mailto:[email protected]] On > Behalf Of Jean-Noël Monette > Sent: Friday, March 23, 2012 6:05 PM > To: [email protected] > Subject: [gecode-users] Questions about the range iterators > > Hello, > > I have a few questions about range iterators. Those questions are maybe more > reflexions that I hope you will confirm or correct if I misunderstood something. > Thank you in advance. > > * Some iterators (those that are not templated), like NaryUnion or Minus, > maintain their own data structure for the ranges, while the other ones (most of > them) rely on the information provided by other iterators. > > * A very few iterators (based on RangeListIter) have a reset() method allowing > one to restart the iteration from scratch. The other ones do not have this > functionality. What is the rational behind this choice? I was thinking about the > way/cost of adding a reset method to all iterators and it looks to me that it > might be easy enough. But maybe you have no interest in doing this (as it > typically requires some more pointers (e.g. in classes such as IntVarImpFwd) for > only an occasional use), or there are some hidden difficulties (I'm certainly not > expert in the implementation of Gecode). > > * From the previous point, most iterators are "one-use" only and are unusable > once consumed. If one wants to use twice the same iterator for some reason, > he has to recreate it from scratch. Is it right? Or is there some other way to do it > (e.g. with a copy constructor)? > > Thank you for your help, > > Jean-Noël Monette > > _______________________________________________ > Gecode users mailing list > [email protected] > https://www.gecode.org/mailman/listinfo/gecode-users _______________________________________________ Gecode users mailing list [email protected] https://www.gecode.org/mailman/listinfo/gecode-users
