Id keep the design: it makes update explicit and has the advantage that it can be done outside the intializer list. Quite often, propagators do some cleanup before they call update on their datastructures.
Christian From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Javier Andrés Mena Zapata Sent: Wednesday, November 19, 2008 10:29 PM To: gecode list Subject: Re: [gecode-users] Starting with C++ Hi Christian, If one of the reasons, is historical, and supossing you must/want to reimplement it, then would you implement Gecode using the same design? If no, then how would you implement it? Thanks, On Wed, Nov 19, 2008 at 5:24 AM, Christian Schulte <[EMAIL PROTECTED]> wrote: Hi Malcolm, all your questions have a yes as the answer. Having the possibility to construct variables in an uninitialized state is actually quite useful (think of just declaring an integer variable without initializing, same thing). It might not useful during copying but in other situations (in particular think of an array of variables - such as IntVarArgs - you would like to pass as an argument, here you definitely do not want to create a variable first and then overwrite it). The reason why copying an array is not controlled by a copy constructor but by an update function is for two reasons: one, historical (because in earlier versions the constructor would have clashed with other constructors) and the other uniformity (for some data structures it is not very easy to define a constructor, but it is easy to have a separate update function). Cheers Christian -- Christian Schulte, www.ict.kth.se/~cschulte/ <http://www.ict.kth.se/%7Ecschulte/> -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Malcolm Ryan Sent: Wednesday, November 19, 2008 5:06 AM To: gecode list Subject: [gecode-users] Starting with C++ Given that GecodeJ is no longer supported, I'm in the process of migrating my code to C++ (and learning C++ in the process). It seems from my perusal of the examples that the C++ library works slightly differently. Whereas in java the copy constructors for spaces look like: public Queens(Boolean share, Queens queens) { super(share, queens); n = queens.n; q = new VarArray<IntVar>(this, share, queens.q); } in C++ they look like: /// Constructor for cloning \a s Queens(bool share, Queens& s) : Example(share,s) { q.update(this, share, s.q); } The Java code explicitly contructs a new var array from the old. The C+ + code seems to implicitly construct an empty var array and then call 'update' to copy the old into the new. Is that correct? Does every kind of variable have an no-arg constructor? What is the rationale for this choice? It seems that it allows you to construct variables in an incompletely initialised state. Is that deliberate? Malcolm _______________________________________________ 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 -- "La buena educación, es lo que nos queda cuando se nos olvida todo lo que nos han enseñado" ¿? Javier Andrés Mena Zapata http://StrategicDecision.net/ +57 (2) 318 1000 ext. 2910 Cali - Colombia
_______________________________________________ Gecode users mailing list [EMAIL PROTECTED] https://www.gecode.org/mailman/listinfo/gecode-users