protected void Merge(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC) { DFANodes = new List <DFANode>(Compare.Max <int>(dfaMatrixA.DFANodes.Count, dfaMatrixB.DFANodes.Count, dfaMatrixC.DFANodes.Count) + 128); DFANodes.Add(new DFANode()); DFANodes.Add(new DFANode()); DFAMatrixCache3 cache = new DFAMatrixCache3(DFANodes.Capacity); Product(dfaMatrixA, 1, dfaMatrixB, 1, dfaMatrixC, 1, cache); }
protected void Product(DFAMatrix dfaLeft, int left, DFAMatrix dfaMiddle, int middle, DFAMatrix dfaRight, int right, DFAMatrixCache3 cache) { int lState = DFANodes.Count - 1; AttributeUnion(DFANodes[lState], dfaLeft.DFANodes[left], dfaMiddle.DFANodes[middle], dfaRight.DFANodes[right]); for (int c = 0; c != 4; c++) { int lNextL = dfaLeft.DFANodes[left][c]; int lNextM = dfaMiddle.DFANodes[middle][c]; int lNextR = dfaRight.DFANodes[right][c]; if ((lNextL != 0) || (lNextM != 0) || (lNextR != 0)) { int lNewValue = cache.Search(lNextL, lNextM, lNextR); if (lNewValue == 0) { // create it int lLastState = DFANodes.Count; DFANodes.Add(new DFANode()); cache.Add(lNextL, lNextM, lNextR, lLastState); DFANodes[lState][c] = lLastState; Product(dfaLeft, lNextL, dfaMiddle, lNextM, dfaRight, lNextR, cache); } else { // link to it DFANodes[lState][c] = lNewValue; } } else { DFANodes[lState][c] = 0; } } }
protected void Merge(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC) { DFANodes = new List<DFANode>(Compare.Max<int>(dfaMatrixA.DFANodes.Count, dfaMatrixB.DFANodes.Count, dfaMatrixC.DFANodes.Count) + 128); DFANodes.Add(new DFANode()); DFANodes.Add(new DFANode()); DFAMatrixCache3 cache = new DFAMatrixCache3(DFANodes.Capacity); Product(dfaMatrixA, 1, dfaMatrixB, 1, dfaMatrixC, 1, cache); }