public void AddConnection(GateConnection connection) { // create a connection from output to input if (OutputConnectionCounterparties.ContainsKey(connection.FromAddr)) { // the "from" in this connection already has a counterparty. want to remove it var oldTo = OutputConnectionCounterparties[connection.FromAddr]; InputConnectionCounterparties.Remove(oldTo); InputAddrs.Add(oldTo); } if (InputConnectionCounterparties.ContainsKey(connection.ToAddr)) { // the "to" in this connection already has a counterparty. want to remove it var oldFrom = InputConnectionCounterparties[connection.ToAddr]; OutputConnectionCounterparties.Remove(oldFrom); OutputAddrs.Add(oldFrom); } OutputConnectionCounterparties[connection.FromAddr] = connection.ToAddr; OutputAddrs.Remove(connection.FromAddr); InputConnectionCounterparties[connection.ToAddr] = connection.FromAddr; InputAddrs.Remove(connection.ToAddr); TopologicalOrderImpl = null; }
public void AddGate(Gate gate, IEnumerable <GateConnection> connections) { // insert before checks to allow loopback Gates.Add(gate); for (int i = 0; i < gate.InputCount; i++) { InputAddrs.Add(new InputGateAddress(gate, i)); } for (int i = 0; i < gate.OutputCount; i++) { OutputAddrs.Add(new OutputGateAddress(gate, i)); } foreach (var connection in connections) { AddConnection(connection); } TopologicalOrderImpl = null; }