def addOperation(self, OperationType, NodeA, NodeB = None): # search for the Operation with the Same Properties i = 0 while i < len(self.Content): if (self.Content[i].OperationType == OperationType) and \ (self.Content[i].NodeA == NodeA) and \ (self.Content[i].NodeB == NodeB): # ... return i i += 1 NewElement = DAGElement(OperationType) NewElement.NodeA = NodeA NewElement.NodeB = NodeB self.Content.append(NewElement) return i
def addVariable(self, VarId, Check = True): # search for the Operation with the Same Properties i = 0 if Check: while i < len(self.Content): if (self.Content[i].OperationType == DAGElement.EnumOperationType.VAR) and \ (self.Content[i].VarId == VarId): # ... return i i += 1 else: i = len(self.Content) NewElement = DAGElement(DAGElement.EnumOperationType.VAR) NewElement.VarId = VarId self.Content.append(NewElement) return i