public override bool Equals(object obj) { if (obj is null) { return(false); } if (!(obj is VirtualForestNodePath virtualForestNodePath)) { return(false); } return(TransitionState.Equals(virtualForestNodePath.TransitionState) && ForestNode.Equals(virtualForestNodePath.ForestNode)); }
public override bool Equals(object obj) { if (((object)obj) == null) { return(false); } var virtualForestNodePath = obj as VirtualForestNodePath; if (((object)virtualForestNodePath) == null) { return(false); } return(TransitionState.Equals(virtualForestNodePath.TransitionState) && ForestNode.Equals(virtualForestNodePath.ForestNode)); }
static int GetSerializedFsa(TransitionState stateStart, Hashset setAllState, Hashset setAllSymbols, StringBuilder sb) { int lineLength = 0; int minWidth = 6; string line = String.Empty; string format = String.Empty; setAllSymbols.RemoveElement(MetaSymbol.EPSILON); setAllSymbols.AddElement(MetaSymbol.EPSILON); object[] symbolObjects = new object[setAllSymbols.Count + 1]; symbolObjects[0] = "State"; format = "{0,-8}"; for (int i = 0; i < setAllSymbols.Count; i++) { string sSymbol = setAllSymbols[i].ToString(); symbolObjects[i + 1] = sSymbol; format += " | "; format += "{" + (i + 1).ToString() + ",-" + Math.Max(Math.Max(sSymbol.Length, minWidth), sSymbol.ToString().Length) + "}"; } line = String.Format(format, symbolObjects); lineLength = Math.Max(lineLength, line.Length); sb.AppendLine(("").PadRight(lineLength, '-')); sb.AppendLine(line); sb.AppendLine(("").PadRight(lineLength, '-')); int nTransCount = 0; foreach (object objState in setAllState) { TransitionState state = (TransitionState)objState; symbolObjects[0] = (state.Equals(stateStart) ? ">" + state.ToString() : state.ToString()); for (int i = 0; i < setAllSymbols.Count; i++) { string sSymbol = setAllSymbols[i].ToString(); TransitionState[] arrStateTo = state.GetTransitions(sSymbol); string sTo = String.Empty; if (arrStateTo != null) { nTransCount += arrStateTo.Length; sTo = arrStateTo[0].ToString(); for (int j = 1; j < arrStateTo.Length; j++) { sTo += ", " + arrStateTo[j].ToString(); } } else { sTo = "--"; } symbolObjects[i + 1] = sTo; } line = String.Format(format, symbolObjects); sb.AppendLine(line); lineLength = Math.Max(lineLength, line.Length); } format = "State Count: {0}, Input Symbol Count: {1}, Transition Count: {2}"; line = String.Format(format, setAllState.Count, setAllSymbols.Count, nTransCount); lineLength = Math.Max(lineLength, line.Length); sb.AppendLine(("").PadRight(lineLength, '-')); sb.AppendLine(line); lineLength = Math.Max(lineLength, line.Length); setAllSymbols.RemoveElement(MetaSymbol.EPSILON); return(lineLength); }