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 RemoveGate(Gate gate) { for (int i = 0; i < gate.InputCount; i++) { var inAddr = gate.GetLocalInputAddress(i); Debug.Assert(!InputConnectionCounterparties.ContainsKey(inAddr)); InputAddrs.Remove(inAddr); } for (int i = 0; i < gate.OutputCount; i++) { var outAddr = gate.GetLocalOutputAddress(i); Debug.Assert(!OutputConnectionCounterparties.ContainsKey(outAddr)); OutputAddrs.Remove(outAddr); } Gates.Remove(gate); }