[gecode-users] Copying vars and views

Mikael Zayenz Lagerkvist zayenz at gmail.com
Tue Feb 12 07:28:39 CET 2008


On Feb 12, 2008 6:53 AM, Malcolm Ryan <malcolmr at cse.unsw.edu.au> wrote:
> In Gecode/J:
>
> If I have a Space which contains some variables and a Branching which
> contains  views of those variable, what happens when I copy them? Do
> they end up pointing to the 'same' copies? How?

They absolutely end up pointing to the same variable, otherwise the
semantics would differ between the original space and the copy.

Behind the scenes, both an IntVar and an IntView (for example) contain
a pointer to the real variable. During the copying procedure, this
real variable is copied only once, and a forwarding pointer is
recorded so that all instances of IntVars and IntViews pointing to
this variable can follow the forwarding pointer.

Cheers,
Mikael

-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/




More information about the gecode-users mailing list