当前位置: 首页>>代码示例>>C#>>正文


C# State.AddEpsilon方法代码示例

本文整理汇总了C#中State.AddEpsilon方法的典型用法代码示例。如果您正苦于以下问题:C# State.AddEpsilon方法的具体用法?C# State.AddEpsilon怎么用?C# State.AddEpsilon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在State的用法示例。


在下文中一共展示了State.AddEpsilon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Optional

 /// <summary>
 /// Returns an automaton that accepts the union of the empty string and the language of the 
 /// given automaton.
 /// </summary>
 /// <param name="a">The automaton.</param>
 /// <remarks>
 /// Complexity: linear in number of states.
 /// </remarks>
 /// <returns>An automaton that accepts the union of the empty string and the language of the 
 /// given automaton.</returns>
 public static Automaton Optional(Automaton a)
 {
     a = a.CloneExpandedIfRequired();
     var s = new State();
     s.AddEpsilon(a.Initial);
     s.Accept = true;
     a.Initial = s;
     a.IsDeterministic = false;
     a.ClearHashCode();
     a.CheckMinimizeAlways();
     return a;
 }
开发者ID:unity-alex,项目名称:Fare,代码行数:22,代码来源:BasicOperations.cs

示例2: Repeat

        /// <summary>
        /// Accepts the Kleene star (zero or more concatenated repetitions) of the language of the
        /// given automaton. Never modifies the input automaton language.
        /// </summary>
        /// <param name="a">The automaton.</param>
        /// <returns>
        /// An automaton that accepts the Kleene star (zero or more concatenated repetitions)
        /// of the language of the given automaton. Never modifies the input automaton language.
        /// </returns>
        /// <remarks>
        /// Complexity: linear in number of states.
        /// </remarks>
        public static Automaton Repeat(Automaton a)
        {
            a = a.CloneExpanded();
            var s = new State();
            s.Accept = true;
            s.AddEpsilon(a.Initial);
            foreach (State p in a.GetAcceptStates())
            {
                p.AddEpsilon(s);
            }

            a.Initial = s;
            a.IsDeterministic = false;
            a.ClearHashCode();
            a.CheckMinimizeAlways();
            return a;
        }
开发者ID:unity-alex,项目名称:Fare,代码行数:29,代码来源:BasicOperations.cs

示例3: Union

        /// <summary>
        /// Returns an automaton that accepts the union of the languages of the given automata.
        /// </summary>
        /// <param name="automatons">The l.</param>
        /// <returns>
        /// An automaton that accepts the union of the languages of the given automata.
        /// </returns>
        /// <remarks>
        /// Complexity: linear in number of states.
        /// </remarks>
        public static Automaton Union(IList<Automaton> automatons)
        {
            var ids = new HashSet<int>();
            foreach (Automaton a in automatons)
            {
                ids.Add(RuntimeHelpers.GetHashCode(a));
            }

            bool hasAliases = ids.Count != automatons.Count;
            var s = new State();
            foreach (Automaton b in automatons)
            {
                if (b.IsEmpty)
                {
                    continue;
                }

                Automaton bb = b;
                bb = hasAliases ? bb.CloneExpanded() : bb.CloneExpandedIfRequired();

                s.AddEpsilon(bb.Initial);
            }

            var automaton = new Automaton();
            automaton.Initial = s;
            automaton.IsDeterministic = false;
            automaton.ClearHashCode();
            automaton.CheckMinimizeAlways();
            return automaton;
        }
开发者ID:unity-alex,项目名称:Fare,代码行数:40,代码来源:BasicOperations.cs


注:本文中的State.AddEpsilon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。