@Test(groups = "1s") public void testSubscribe1() throws Exception { props[0].setVIndices(0,v.subscribe(props[0], 0, 4)); Assert.assertEquals(v.propagators[0], props[0]); Assert.assertEquals(v.pindices[0], 0); Assert.assertEquals(props[0].getVIndices(), new int[]{0}); props[1].setVIndices(1, v.subscribe(props[1], 1, 4)); Assert.assertEquals(v.propagators[0], props[1]); Assert.assertEquals(v.pindices[0], 1); Assert.assertEquals(v.propagators[1], props[0]); Assert.assertEquals(v.pindices[1], 0); Assert.assertEquals(props[0].getVIndices(), new int[]{1}); Assert.assertEquals(props[1].getVIndices(), new int[]{-1, 0}); props[2].setVIndices(2, v.subscribe(props[2], 2, 4)); Assert.assertEquals(v.propagators[0], props[2]); Assert.assertEquals(v.pindices[0], 2); Assert.assertEquals(v.propagators[1], props[0]); Assert.assertEquals(v.pindices[1], 0); Assert.assertEquals(v.propagators[2], props[1]); Assert.assertEquals(v.pindices[2], 1); Assert.assertEquals(props[0].getVIndices(), new int[]{1}); Assert.assertEquals(props[1].getVIndices(), new int[]{-1, 2}); Assert.assertEquals(props[2].getVIndices(), new int[]{-1, -1, 0}); props[3].setVIndices(3, v.subscribe(props[3], 3, 4)); Assert.assertEquals(v.propagators[0], props[3]); Assert.assertEquals(v.pindices[0], 3); Assert.assertEquals(v.propagators[1], props[0]); Assert.assertEquals(v.pindices[1], 0); Assert.assertEquals(v.propagators[2], props[1]); Assert.assertEquals(v.pindices[2], 1); Assert.assertEquals(v.propagators[3], props[2]); Assert.assertEquals(v.pindices[3], 2); Assert.assertEquals(props[0].getVIndices(), new int[]{1}); Assert.assertEquals(props[1].getVIndices(), new int[]{-1, 2}); Assert.assertEquals(props[2].getVIndices(), new int[]{-1, -1, 3}); Assert.assertEquals(props[3].getVIndices(), new int[]{-1, -1, -1, 0}); props[4].setVIndices(4, v.subscribe(props[4], 4, 4)); Assert.assertEquals(v.propagators[0], props[4]); Assert.assertEquals(v.pindices[0], 4); Assert.assertEquals(v.propagators[1], props[0]); Assert.assertEquals(v.pindices[1], 0); Assert.assertEquals(v.propagators[2], props[1]); Assert.assertEquals(v.pindices[2], 1); Assert.assertEquals(v.propagators[3], props[2]); Assert.assertEquals(v.pindices[3], 2); Assert.assertEquals(v.propagators[4], props[3]); Assert.assertEquals(v.pindices[4], 3); Assert.assertEquals(props[0].getVIndices(), new int[]{1}); Assert.assertEquals(props[1].getVIndices(), new int[]{-1, 2}); Assert.assertEquals(props[2].getVIndices(), new int[]{-1, -1, 3}); Assert.assertEquals(props[3].getVIndices(), new int[]{-1, -1, -1, 4}); Assert.assertEquals(props[4].getVIndices(), new int[]{-1, -1, -1, -1, 0}); }
int subscribe(Propagator p, int ip, int i) { int j = dsize - 1; for (; j >= i; j--) { move(dindices[j], dindices[j + 1]); dindices[j + 1]++; } propagators[dindices[i]] = p; pindices[dindices[i]] = ip; return dindices[i]; }
AbstractVariable implements Variable { int subscribe(Propagator p, int ip, int i) { int j = dsize - 1; for (; j >= i; j--) { move(dindices[j], dindices[j + 1]); dindices[j + 1]++; } propagators[dindices[i]] = p; pindices[dindices[i]] = ip; return dindices[i]; } }
AbstractVariable implements Variable { int subscribe(Propagator p, int ip, int i) { int j = dsize - 1; for (; j >= i; j--) { move(dindices[j], dindices[j + 1]); dindices[j + 1]++; } propagators[dindices[i]] = p; pindices[dindices[i]] = ip; return dindices[i]; } protected  AbstractVariable(String name, Model model); }
AbstractVariable implements Variable { int subscribe(Propagator p, int ip, int i) { int j = dsize - 1; for (; j >= i; j--) { move(dindices[j], dindices[j + 1]); dindices[j + 1]++; } propagators[dindices[i]] = p; pindices[dindices[i]] = ip; return dindices[i]; } protected  AbstractVariable(String name, Model model); @Override final int getId(); @Override final int link(Propagator propagator, int idxInProp); @Override int swapOnPassivate(Propagator propagator, int idxInProp); @Override int swapOnActivate(Propagator propagator, int idxInProp); @Override final void unlink(Propagator propagator, int idxInProp); @Override final Propagator[] getPropagators(); @Override final Propagator getPropagator(int idx); @Override final int getNbProps(); @Override final int[] getPIndices(); @Override final void setPIndice(int pos, int val); @Override final int getDindex(int i); @Override final int getIndexInPropagator(int pidx); @Override final String getName(); @Override void notifyPropagators(IEventType event, ICause cause); void notifyMonitors(IEventType event); @Override void notifyViews(IEventType event, ICause cause); @Override void addMonitor(IVariableMonitor monitor); @Override void removeMonitor(IVariableMonitor monitor); @Override void subscribeView(IView view); @Override final void contradiction(ICause cause, String message); final Model getModel(); @Override int getNbViews(); @Override IView getView(int idx); @Override int compareTo(Variable o); @Override String toString(); final boolean isBool(); final boolean isAConstant(); @SuppressWarnings("unchecked") final EvtScheduler getEvtScheduler(); @Override IntVar asIntVar(); @Override BoolVar asBoolVar(); @Override RealVar asRealVar(); @Override SetVar asSetVar(); @Override void storeEvents(int m, ICause cause); @Override void clearEvents(); @Override int getMask(); @Override ICause getCause(); }
AbstractVariable implements Variable { int subscribe(Propagator p, int ip, int i) { int j = dsize - 1; for (; j >= i; j--) { move(dindices[j], dindices[j + 1]); dindices[j + 1]++; } propagators[dindices[i]] = p; pindices[dindices[i]] = ip; return dindices[i]; } protected  AbstractVariable(String name, Model model); @Override final int getId(); @Override final int link(Propagator propagator, int idxInProp); @Override int swapOnPassivate(Propagator propagator, int idxInProp); @Override int swapOnActivate(Propagator propagator, int idxInProp); @Override final void unlink(Propagator propagator, int idxInProp); @Override final Propagator[] getPropagators(); @Override final Propagator getPropagator(int idx); @Override final int getNbProps(); @Override final int[] getPIndices(); @Override final void setPIndice(int pos, int val); @Override final int getDindex(int i); @Override final int getIndexInPropagator(int pidx); @Override final String getName(); @Override void notifyPropagators(IEventType event, ICause cause); void notifyMonitors(IEventType event); @Override void notifyViews(IEventType event, ICause cause); @Override void addMonitor(IVariableMonitor monitor); @Override void removeMonitor(IVariableMonitor monitor); @Override void subscribeView(IView view); @Override final void contradiction(ICause cause, String message); final Model getModel(); @Override int getNbViews(); @Override IView getView(int idx); @Override int compareTo(Variable o); @Override String toString(); final boolean isBool(); final boolean isAConstant(); @SuppressWarnings("unchecked") final EvtScheduler getEvtScheduler(); @Override IntVar asIntVar(); @Override BoolVar asBoolVar(); @Override RealVar asRealVar(); @Override SetVar asSetVar(); @Override void storeEvents(int m, ICause cause); @Override void clearEvents(); @Override int getMask(); @Override ICause getCause();  }