@Test public void testTwoBinary() { Passthrough p1 = new Passthrough(2); QueueSink qs1 = new QueueSink(2); Connector.connect(p1, 0, qs1, 1); Connector.connect(p1, 1, qs1, 0); Pushable push1 = p1.getPushableInput(0); Pushable push2 = p1.getPushableInput(1); for (int k = 0; k < 2; k++) { Queue<Object> queue1 = qs1.getQueue(0); Queue<Object> queue2 = qs1.getQueue(1); for (int i = 0; i < 5; i++) { push1.push(i); push2.push(2 * i + 1); Utilities.queueContains(i, queue2); Utilities.queueContains(2 * i + 1, queue1); } p1.reset(); qs1.reset(); } }
public static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j) { if (s_checkForTypes) { checkForException(p1, i, p2, j); } if (p1 == p2) { throw new SelfLoopException(p1, i, p2, j); } try { Pullable p1_out = p1.getPullableOutput(i); p2.setPullableInput(j, p1_out); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } try { Pushable p2_in = p2.getPushableInput(j); p1.setPushableOutput(i, p2_in); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } if (tracker != null) { tracker.setConnection(p1.getId(), i, p2.getId(), j); } return p2; }
Connector { public static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j) { if (s_checkForTypes) { checkForException(p1, i, p2, j); } if (p1 == p2) { throw new SelfLoopException(p1, i, p2, j); } try { Pullable p1_out = p1.getPullableOutput(i); p2.setPullableInput(j, p1_out); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } try { Pushable p2_in = p2.getPushableInput(j); p1.setPushableOutput(i, p2_in); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } if (tracker != null) { tracker.setConnection(p1.getId(), i, p2.getId(), j); } return p2; } }
Connector { public static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j) { if (s_checkForTypes) { checkForException(p1, i, p2, j); } if (p1 == p2) { throw new SelfLoopException(p1, i, p2, j); } try { Pullable p1_out = p1.getPullableOutput(i); p2.setPullableInput(j, p1_out); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } try { Pushable p2_in = p2.getPushableInput(j); p1.setPushableOutput(i, p2_in); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } if (tracker != null) { tracker.setConnection(p1.getId(), i, p2.getId(), j); } return p2; } private  Connector(); }
Connector { public static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j) { if (s_checkForTypes) { checkForException(p1, i, p2, j); } if (p1 == p2) { throw new SelfLoopException(p1, i, p2, j); } try { Pullable p1_out = p1.getPullableOutput(i); p2.setPullableInput(j, p1_out); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } try { Pushable p2_in = p2.getPushableInput(j); p1.setPushableOutput(i, p2_in); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } if (tracker != null) { tracker.setConnection(p1.getId(), i, p2.getId(), j); } return p2; } private  Connector(); static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j); static Processor connect(Processor p1, int i, Processor p2, int j); static Processor connect(Processor ... procs); static Processor connect(EventTracker tracker, Processor ... procs); @SuppressWarnings("squid:S1166") static boolean isCompatible(Processor p1, int i, Processor p2, int j); static Collection<Connection> getConnections(Processor p); }
Connector { public static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j) { if (s_checkForTypes) { checkForException(p1, i, p2, j); } if (p1 == p2) { throw new SelfLoopException(p1, i, p2, j); } try { Pullable p1_out = p1.getPullableOutput(i); p2.setPullableInput(j, p1_out); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } try { Pushable p2_in = p2.getPushableInput(j); p1.setPushableOutput(i, p2_in); } catch (ArrayIndexOutOfBoundsException e) { throw new Connector.IndexOutOfBoundsException(p1, i, p2, j); } catch (UnsupportedOperationException e) { } if (tracker != null) { tracker.setConnection(p1.getId(), i, p2.getId(), j); } return p2; } private  Connector(); static Processor connect(EventTracker tracker, Processor p1, int i, Processor p2, int j); static Processor connect(Processor p1, int i, Processor p2, int j); static Processor connect(Processor ... procs); static Processor connect(EventTracker tracker, Processor ... procs); @SuppressWarnings("squid:S1166") static boolean isCompatible(Processor p1, int i, Processor p2, int j); static Collection<Connection> getConnections(Processor p); static final boolean s_checkForTypes; static final boolean s_checkForBounds; static final int INPUT; static final int OUTPUT; static final int LEFT; static final int TOP; static final int RIGHT; static final int BOTTOM; }