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


C# Seq.Insert方法代码示例

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


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

示例1: insertPoints

        /// <summary>
        /// Inserts numP points into the polygon
        /// </summary>
        /// <param name="poly">Eequence of points representing the polygon border</param>
        /// <param name="numP">Number of points to insert</param>
        void insertPoints(ref Seq<Point> poly, ref PolyFromTris triPoly, int numP, int iw, int ih)
        {
            ///////////////////////////////////////////// TODO: FIX !!!!!!
            Seq<PointF> testsek = new Seq<PointF>(new MemStorage());

            foreach (Point p in poly)
            {
                testsek.Insert(testsek.Total, new PointF((float)p.X, (float)p.Y));
            }

            Rectangle rect = testsek.BoundingRectangle;
            ////////////////////////////////////////


            //
            // Calculate BoundingBox to narrow random-inserting points area
          //  Rectangle rect = poly.BoundingRectangle;

            int maxIter = numP*500;

            while (numP > 0) // We want inside numP random points
            {
                if (maxIter-- <= 0) break;

                // Generate point inside BBox
                Point p = new Point(random.Next(rect.X, rect.X + rect.Width), random.Next(rect.Y, rect.Y+rect.Height));

                if (p.X > iw || p.Y > ih || p.Y < 0 || p.X<0) continue;

                if (poly.InContour(p) > 0) // If point is on the poly
                {

                    triPoly.addInnerPoint(new PointF((float)p.X, (float)p.Y));
                    poly.Insert(poly.Total, p); // Insert it to our list
                    numP--;
                }
 
            } 
        }
开发者ID:aljosaosep,项目名称:holdrecognition,代码行数:44,代码来源:HoldTriangulation.cs

示例2: PrefixName

        // Imports:
        //  - instance methods: no qualification
        //  - static methods & constructors: add qualification
        // Exports:
        //  - instance methods, not prototype bound: no qualification
        //  - instance methods, prototype bound: add qualification and 'prototype'
        //  - static methods & constructors: add qualification
        private JST.Expression PrefixName(MessageContext ctxt, CCI.Member member, JST.Expression script, bool isExport)
        {
            if (script != null && script is JST.FunctionExpression)
                return script;

            var isNonInstance = member.IsStatic || member is CCI.InstanceInitializer;
            var qual = interopTypes.GetValue
                (ctxt, member, env.NamingAttributeType, interopTypes.TheQualificationProperty);
            var isProto = isExport &&
                          interopTypes.GetValue
                              (ctxt,
                               member,
                               env.ExportAttributeType,
                               interopTypes.TheBindToPrototypeProperty);
            var path = new Seq<JST.PropertyName>();

            if (script == null && member is CCI.InstanceInitializer && qual == Qualification.None)
                qual = Qualification.Type;

            if (!isExport && !isNonInstance && qual != Qualification.None)
                qual = Qualification.None;

            if (isExport && !isNonInstance && !isProto && qual != Qualification.None)
                qual = Qualification.None;

            if (isExport && !isNonInstance && isProto && qual == Qualification.None)
                qual = Qualification.Type;

            if (isNonInstance)
            {
                var global = interopTypes.GetValue
                    (ctxt, member, env.NamingAttributeType, interopTypes.TheGlobalObjectProperty);
                if (global != null)
                {
                    if (global is JST.FunctionExpression)
                    {
                        env.Log(new InvalidInteropMessage
                            (RewriterMsgContext.Member(ctxt, member), "global object expression cannot be a function"));
                        throw new DefinitionException();
                    }
                    foreach (var p in JST.Expression.ExplodePath(global))
                        path.Add(p);
                }
            }

            if (qual == Qualification.Full)
            {
                var nsCasing = interopTypes.GetValue
                    (ctxt, member, env.NamingAttributeType, interopTypes.TheNamespaceCasingProperty);
                foreach (var name in member.DeclaringType.Namespace.Name.Split('.'))
                {
                    if (string.IsNullOrEmpty(name))
                    {
                        env.Log(new InvalidInteropMessage
                            (RewriterMsgContext.Member(ctxt, member),
                             "member's namespace cannot be represented in JavaScript"));
                        throw new DefinitionException();
                    }
                    path.Add(new JST.PropertyName(Recase(name, nsCasing)));
                }
            }

            if (qual == Qualification.Full || qual == Qualification.Type)
            {
                var type = member.DeclaringType;
                var i = path.Count;
                do
                {
                    var tnCasing = interopTypes.GetValue
                        (ctxt, type, env.NamingAttributeType, interopTypes.TheTypeNameCasingProperty);
                    path.Insert(i, new JST.PropertyName(Recase(type.Name.Name, tnCasing)));
                    type = type.DeclaringType;
                }
                while (type != null);
            }

            if (isProto)
                path.Add(new JST.PropertyName(Constants.prototype));

            if (script != null)
            {
                foreach (var p in JST.Expression.ExplodePath(script))
                    path.Add(p);
            }

            return JST.Expression.Path(path);
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:94,代码来源:InteropManager.cs

示例3: FinalImportScript


//.........这里部分代码省略.........

                if (lastArgIsParamsArray)
                {
                    var argsId = gensym();
                    body.Add(JST.Statement.Var(argsId, new JST.ArrayLiteral()));

                    if (scriptExpectsRoot)
                        body.Add(JST.Statement.DotCall(argsId.ToE(), Constants.push, rootId.ToE()));

                    if (!isInstanceMethod)
                        callArgs.Add(new JST.NullExpression());

                    for (var i = 0; i < methodArity; i++)
                    {
                        var id = gensym();
                        parameters.Add(id);
                        if (isInstanceMethod && i == 0)
                        {
                            if (instanceIsThis)
                                callArgs.Add(id.ToE());
                            else
                            {
                                callArgs.Add(new JST.NullExpression());
                                body.Add(JST.Statement.DotCall(argsId.ToE(), Constants.push, id.ToE()));
                            }
                        }
                        else if (i == methodArity - 1)
                        {
                            var iId = gensym();
                            body.Add
                                (new JST.IfStatement
                                     (JST.Expression.IsNotNull(id.ToE()),
                                      new JST.Statements
                                          (new JST.ForStatement
                                               (new JST.ForVarLoopClause
                                                    (iId,
                                                     new JST.NumericLiteral(0),
                                                     new JST.BinaryExpression
                                                         (iId.ToE(),
                                                          JST.BinaryOp.LessThan,
                                                          JST.Expression.Dot(id.ToE(), Constants.length)),
                                                     new JST.UnaryExpression(iId.ToE(), JST.UnaryOp.PostIncrement)),
                                                new JST.Statements
                                                    (JST.Statement.DotCall
                                                         (argsId.ToE(),
                                                          Constants.push,
                                                          new JST.IndexExpression(id.ToE(), iId.ToE())))))));
                        }
                        else
                            body.Add(JST.Statement.DotCall(argsId.ToE(), Constants.push, id.ToE()));
                    }
                    if (script is JST.FunctionExpression)
                    {
                        var funcId = gensym();
                        body.Add(JST.Statement.Var(funcId, script));
                        script = JST.Expression.Dot(funcId.ToE(), Constants.apply);
                    }
                    else
                        script = JST.Expression.Dot(script, Constants.apply);
                    callArgs.Add(argsId.ToE());
                }
                else
                {
                    if (scriptExpectsRoot)
                        callArgs.Add(rootId.ToE());

                    for (var i = 0; i < methodArity; i++)
                    {
                        var id = gensym();
                        parameters.Add(id);
                        if (i == 0 && instanceIsThis)
                        {
                            if (script is JST.FunctionExpression)
                            {
                                callArgs.Insert(0, id.ToE());
                                var funcId = gensym();
                                body.Add(JST.Statement.Var(funcId, script));
                                script = JST.Expression.Dot(funcId.ToE(), Constants.call);
                            }
                            else
                                script = JST.Expression.Dot(id.ToE(), JST.Expression.ExplodePath(script));
                        }
                        else
                            callArgs.Add(id.ToE());
                    }
                }

                var exp = (JST.Expression)new JST.CallExpression(script, callArgs);
                if (isNew)
                    exp = new JST.NewExpression(exp);

                if (ReturnType(methodDefn) == null)
                    body.Add(new JST.ExpressionStatement(exp));
                else
                    body.Add(new JST.ReturnStatement(exp));

                function = new JST.FunctionExpression(parameters, new JST.Statements(body));
            }
            return new ImportMethodInfo { MethodDefn = methodDefn, Script = function };
        }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:101,代码来源:InteropManager.cs

示例4: TryReduceJump

 private string TryReduceJump(BasicBlock root, JumpBasicBlock jumpbb)
 {
     // Try to find a linear chain of branches of length > 1
     var group = new Set<BasicBlock> { jumpbb };
     var chain = new Seq<BasicBlock> { jumpbb };
     var start = jumpbb;
     while (start.Sources.Count == 1 && start.Sources[0] is JumpBasicBlock &&
            !group.Contains(start.Sources[0]))
     {
         // Extend chain upwards
         start = (JumpBasicBlock)start.Sources[0];
         group.Add(start);
         chain.Insert(0, start);
     }
     var endjump = jumpbb;
     while (endjump.Target.Sources.Count == 1 && endjump.Target is JumpBasicBlock && !group.Contains(endjump.Target))
     {
         // Extend chain downwards
         endjump = (JumpBasicBlock)endjump.Target;
         group.Add(endjump);
         chain.Add(endjump);
     }
     var end = (BasicBlock)endjump;
     if (endjump.Target.Sources.Count == 1 && endjump.Target.AcceptsInstructions && !group.Contains(endjump.Target))
     {
         // Extend chain downwards to include a final non jump basic block, provided we can put all
         // the accumulated instructions there
         end = endjump.Target;
         group.Add(end);
         chain.Add(end);
     }
     if (chain.Count > 1)
     {
         // Coalesce and peephole
         var instructions = new Seq<Instruction>();
         foreach (var bb in chain)
             bb.Block.AccumInstructions(instructions);
         var newbb = end.CloneWithInstructions(nextBlockId++, Peephole(chain[0].Block.BeforeState, instructions));
         root.Coalesce(start, group, newbb);
         return String.Format("collapsed chain of {0} jump blocks from B{1}", chain.Count, start.Id); 
     }
     else if (start.Block.Count == 0 && !start.Target.Equals(start))
     {
         // Short-circuit a trivial jump
         root.Delete(start);
         return String.Format("short-circuited trivial jump at B{0}", start.Id);
     }
     else if (start.Target.Equals(start))
     {
         // loop
         var li = new LoopInstruction(NextInstructionId--, start.Block)
                   { BeforeState = jumpbb.Block.BeforeState, AfterState = jumpbb.Block.AfterState };
         var newbb = new NonReturningBasicBlock(nextBlockId++, new Instructions(li));
         root.Coalesce(start, new Set<BasicBlock> { start }, newbb);
         return String.Format("trival loop at B{0}", start.Id);
     }
     else
         return null;
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:59,代码来源:ControlFlowRecovery.cs


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