示例#1
0
        public void Visit(Action <GeneNode> function)
        {
            function.Invoke(this);

            if (Transitions != null && Transitions.Any())
            {
                Transitions.ForEach(d => d.Node.Visit(function));
            }
        }
示例#2
0
        /// <summary>
        /// Don't work with loops!!
        /// </summary>
        /// <param name="letters"></param>
        public void GetAllConditionLetters(List <string> letters)
        {
            var keys = CurrentCondition.Keys;

            foreach (var key in keys)
            {
                if (!letters.Contains(key))
                {
                    letters.Add(key);
                }
            }

            Transitions?.ForEach(f => f.Node.GetAllConditionLetters(letters));
        }
示例#3
0
        public override String ToString()
        {
            String newLine        = Environment.NewLine;
            String tab            = "\t";
            String quoteChar      = "'";
            String commaSeparator = ", ";
            String type           = tab + quoteChar + AutomataType.ToString() + quoteChar;
            String states         = "";
            String symbols        = "";
            String initialState   = tab + quoteChar + InitialState?.ToString() + quoteChar;
            String finalStates    = tab;
            String transitions    = "";

            States.ForEach(
                x => states += quoteChar + x.ToString() + quoteChar + commaSeparator
                );
            if (states.Length >= 3)
            {
                states = states.Substring(0, states.Length - 2);
            }
            Symbols.ForEach(
                x => symbols += quoteChar + x + quoteChar + commaSeparator
                );
            if (symbols.Length >= 3)
            {
                symbols = symbols.Substring(0, symbols.Length - 2);
            }
            FinalStates.ForEach(
                x => finalStates += quoteChar + x.ToString() + quoteChar + commaSeparator
                );
            if (finalStates.Length >= 3)
            {
                finalStates = finalStates.Substring(0, finalStates.Length - 2);
            }
            Transitions.ForEach(
                x => transitions += tab + quoteChar + x.ToString() + quoteChar + newLine
                );

            return
                ($"Type: {newLine}{type}{newLine}" +
                 $"States: {newLine}{tab}{states}{newLine}" +
                 $"Symbols: {newLine}{tab}{symbols}{newLine}" +
                 $"InitialState: {newLine}{initialState}{newLine}" +
                 $"FinalStates: {newLine}{finalStates}{newLine}" +
                 $"Transitions: {newLine}{transitions}");
        }