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


C# LinkedList.AddAll方法代码示例

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


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

示例1: Main

 public static void Main(String[] args) {
   FooBar fb = new FooBar();
   IList<int> list = new LinkedList<int>();
   list.AddAll(new int[] { 2, 3, 5, 7, 11 });
   list.Map<double>(fb).Apply(Console.WriteLine);
   list.Apply(fb);
 }
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:ThisFun.cs

示例2: apply

 public override IList<Variable> apply(IList<Variable> input)
 {
     var list = new LinkedList<Variable>();
     list.AddAll(input);
     //list.Add(0, );
     list.Insert(0, input[input.Count - 1]);
     return list;
 }
开发者ID:dbremner,项目名称:dotnet-testability-explorer,代码行数:8,代码来源:Duplicate.cs

示例3: Result

            /// <summary>
            ///     检索的分词
            /// </summary>
            /// <returns></returns>
            private List<Term> Result()
            {
                var result = new LinkedList<Term>();
                var length = Graph.Terms.Length - 1;
                for (var i = 0; i < length; i++)
                {
                    if (Graph.Terms[i] != null)
                    {
                        result.Add(Graph.Terms[i]);
                    }
                }

                var last = new LinkedList<Term>();
                foreach (var term in result)
                {
                    if (term.Name.Length >= 3)
                    {
                        var gwi = new GetWordsImpl(term.Name);
                        string temp;
                        while ((temp = gwi.AllWords()) != null)
                        {
                            if (temp.Length < term.Name.Length && temp.Length > 1)
                            {
                                last.Add(new Term(temp, gwi.Offe + term.Offe, TermNatures.Null));
                            }
                        }
                    }
                }

                result.AddAll(last);

                ToAnalysis.SetRealName(Graph, result);
                return result;
            }
开发者ID:echofool,项目名称:Ansj.Net,代码行数:38,代码来源:ToAnalysis.cs

示例4: Update

        public void Update(UpdateArgs args)
        {
            // See if we have a new category
            if (currentCategory == null)
            {
                // Create a category and force the first credit to show
                ChooseCategory();
                Debug("Starting category: {0}", currentCategory);
                newSeconds = 0;
            }

            // If we don't have a category, we are done
            if (currentCategory == null)
            {
                Game.GameMode = new MainMenuMode();
                return;
            }

            // Update any of the displayed ones
            LinkedList<CreditsLine> tmpList = new LinkedList<CreditsLine>();
            tmpList.AddAll(displayed);

            foreach (CreditsLine cl in tmpList)
            {
                // Add the time
                cl.SecondsDisplayed += args.SecondsSinceLastUpdate;

                // If we exceeded the life, kill it
                if (cl.SecondsDisplayed > cl.SecondsToLive)
                {
                    displayed.Remove(cl);
                    sprites.Remove(cl.Sprite);
                    Debug("Removing credit line: {0}", cl.Name);
                }
            }

            // If the displayed and pending list are empty, then we
            // are done
            if (displayed.Count == 0 && pending.Count == 0)
            {
                Debug("Finished category: {0}", currentCategory);
                currentCategory = null;
                return;
            }

            // See if we are showing a new one
            newSeconds -= args.SecondsSinceLastUpdate;

            if (slots > 0 && newSeconds <= 0 && pending.Count > 0)
            {
                // Reset the counter
                newSeconds = 0.2;

                // See if we have too many
                if (displayed.Count <= slots)
                {
                    // Pick a random location for this
                    int kill = slots * 2;

                    while (true)
                    {
                        // Check the kill
                        if (kill-- < 0)
                            break;

                        // Set up some variables
                        int row = Entropy.Next(0, slots);
                        float y = row * CreditsLine.FontSize + FontSize * 2;
                        bool found = false;

                        foreach (CreditsLine cl0 in displayed)
                        {
                            if (cl0.Point.Y == y)
                            {
                                found = true;
                                break;
                            }
                        }

                        // If we found something, try again
                        if (found)
                            continue;

                        // Add a new one
                        CreditsLine cl = pending.RemoveFirst();
                        displayed.Add(cl);
                        cl.Point = new PointF(
                            Entropy.NextFloat(sprites.Size.Width
                                - cl.Sprite.Size.Width - 160) + 80,
                            y);
                        sprites.Add(cl.Sprite);
                        break;
                    }
                }
            }

            // Update the sprites
            sprites.Update(args);
        }
开发者ID:dmoonfire,项目名称:cutegod,代码行数:99,代码来源:CreditsMode.cs

示例5: ParkingSpaceObstacle

        public ParkingSpaceObstacle(World world, Vector2 position, float rotation)
        {
            Vector2[] vertices = new Vector2[8];
            vertices[0] = new Vector2(-3.5f, 1.5f);
            vertices[1] = new Vector2(3.5f, 1.5f);
            vertices[2] = new Vector2(3.5f, -1.5f);
            vertices[3] = new Vector2(-3.5f, -1.5f);
            vertices[4] = new Vector2(-3.5f, -1.45f);
            vertices[5] = new Vector2(3.45f, -1.45f);
            vertices[6] = new Vector2(3.45f, 1.45f);
            vertices[7] = new Vector2(-3.45f, 1.45f);

            for (int i = 0; i < 8; i++)
                vertices[i] *= 10;

            LinkedList<Vertices> vertexSet = new LinkedList<Vertices>();
            vertexSet.AddAll(EarclipDecomposer.ConvexPartition(new Vertices(vertices)));

            foreach (Vertices v in vertexSet)
            {
                Body b = BodyFactory.CreatePolygon(world, v, 1f, position);
                b.BodyType = BodyType.Static;
                b.Rotation = rotation;

                Bodies.Add(b);
            }
        }
开发者ID:jgera,项目名称:AutonomousCar,代码行数:27,代码来源:Obstacle.cs

示例6: UpdatePrayers

        /// <summary>
        /// Updates the prayer viewport to show/include/remove the
        /// top-down views to fit the current view.
        /// </summary>
        private void UpdatePrayers()
        {
            // Build up a list of ones to remove
            LinkedList<Prayer> oldKeys = new LinkedList<Prayer>();
            oldKeys.AddAll(prayerViews.Keys);

            // Loop through the prayers
            float x = Padding;

            foreach (Prayer prayer in Game.State.Prayers)
            {
                // Ignore invisible prayers
                if (!prayer.IsAccepted)
                    continue;

                // See if we have the view
                if (!prayerViews.Contains(prayer))
                {
                    // We need to create the top-down view
                    TopDownViewport tdv = new TopDownViewport(prayer.Board);
                    tdv.BlockFilter = FilterConstruction;

                    // Set the value
                    prayerViews[prayer] = tdv;
                    prayerViewport.Add(tdv);
                }
                else
                {
                    // Remove this from the to-remove (old) list
                    oldKeys.Remove(prayer);
                }

                // Change the location of the viewport
                TopDownViewport v = prayerViews[prayer];
                v.Point = new PointF(x, Padding);

                // Adjust the size based on how close the mouse is to
                // viewport.
                float size = 8;
                float left = Math.Abs(mousePoint.X - v.Point.X);
                float right =
                    Math.Abs(mousePoint.X - (v.Point.X + v.Size.Width));

                // Average these two to get the midpoint
                float average = (left + right) / 2;

                // Only make a different if we are with 64 of it
                if (average <= 64)
                {
                    float ratio = (64 - average) / 64;
                    size += ratio * 8;
                }

                v.BlockHeight = v.BlockWidth = size;

                // Update the new x coordinate
                v.Size = v.Extents.Size;
                x += Padding + v.Size.Width;
            }

            // Anything left in the old list needs to be removed
            foreach (Prayer prayer in oldKeys)
            {
                // Get the viewport
                TopDownViewport ov = prayerViews[prayer];
                prayerViewport.Remove(ov);
                prayerViews.Remove(prayer);
            }
        }
开发者ID:dmoonfire,项目名称:cutegod,代码行数:73,代码来源:IndicatorsViewport.cs

示例7: Draw

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(backgroundLight ? LIGHT : DARK);

            Matrix p = camera.Projection;
            Matrix v = camera.View;

            if (cameraView == 2)
            {
                float orientation = controller != null && controller.InReverse ? car.Pose.Orientation + MathHelper.Pi : car.Pose.Orientation;
                Vector2 position = Car.GetCenterPosition(car.Pose);
                Vector2 headingVector = new Vector2((float)Math.Cos(orientation), (float)Math.Sin(orientation));
                float offset = 14f;
                float height = 10f;
                v = Matrix.CreateLookAt(new Vector3(position + -offset * headingVector, height), new Vector3(position + offset * headingVector, 0f), Vector3.UnitZ);
            }
            else if (cameraView == 3)
            {
                float or = car.Pose.Orientation + MathHelper.ToRadians(120f);
                Vector2 headingVector = new Vector2((float)Math.Cos(or), (float)Math.Sin(or));
                v = Matrix.CreateLookAt(new Vector3(car.Pose.Position + -10f * headingVector, 5f), new Vector3(Car.GetCenterPosition(car.Pose), 0f), Vector3.UnitZ);
            }
            else if (cameraView == 4)
            {
                float or = goalPose.Orientation;
                Vector2 headingVector = new Vector2((float)Math.Cos(or), (float)Math.Sin(or));
                v = Matrix.CreateLookAt(new Vector3(goalPose.Position + 10f * headingVector, 20f), new Vector3(Car.GetCenterPosition(car.Pose), 0f), Vector3.UnitZ);
            }
            else if (cameraView == 5)
            {
                v = Matrix.CreateLookAt(new Vector3(Car.GetCenterPosition(car.Pose), 20f), new Vector3(Car.GetCenterPosition(car.Pose), 0f), Vector3.UnitY);
                if (rotateCar)
                    v *= Matrix.CreateRotationZ(-car.Body.Rotation + MathHelper.PiOver2);
            }

            if (gridDone && (drawGrid || drawVoro || drawHeur))
            {
                basicEffect.World = Matrix.Identity;
                basicEffect.View = v;
                basicEffect.Projection = p;
                spriteBatch.Begin(0, null, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);

                if (drawHeur)
                    HybridAStar.Draw(spriteBatch);
                else
                    grid.Draw(spriteBatch, drawVoro);

                spriteBatch.End();
            }

            debug.BeginCustomDraw(ref p, ref v);

            debug.DrawSolidCircle(Car.GetFrontAxlePosition(car.Pose), 0.2f, Color.Green);

            if ((pathSearching && watchSearch || pathSearchingDone && drawSearch) && HybridAStar.Expanded != null && HybridAStar.Expanded.Count > 0)
            {
                LinkedList<HybridAStar.Node> expanded = new LinkedList<HybridAStar.Node>();
                lock (HybridAStar.Expanded)
                {
                    expanded.AddAll(HybridAStar.Expanded);
                }

                float pathLength = expanded.Last.f;
                foreach (HybridAStar.Node n in expanded)
                {
                    if (pathDone && n.rsIndex >= 0)
                    {
                        for (int i = n.rsIndex; i < poses.Count - 1; i++)
                            debug.DrawSegment(poses[i].Position, poses[i + 1].Position, Color.Purple, 0.02f);
                    }
                    else if (n.from != null)
                    {
                        Color color;
                        if (n.cell.rev == 0)
                            color = Color.Lerp(Color.Orange, Color.Green, n.g / pathLength);
                        else
                            color = Color.Lerp(Color.Blue, Color.Cyan, n.g / pathLength);

                        debug.DrawSegment(n.from.pose.Position, n.pose.Position, color, 0.02f);
                    }
                }
            }

            if (pathDone)
            {
                if (drawPath)
                {
                    for (int i = 0; i < poses.Count - 1; i++)
                    {
                        Color c = poses[i].Gear == Gear.Forward ? Color.Blue : Color.Red;
                        debug.DrawSegment(poses[i].Position, poses[i + 1].Position, c, 0.04f);
                        debug.DrawPoint(poses[i].Position, 0.1f, c * 0.5f);
                    }
                }
            }

            if (pathSearchingDone && !pathSmoothDone && (drawSmoothedPath || drawController))
                Smoother.Draw(debug);

            if (pathSmoothDone)
//.........这里部分代码省略.........
开发者ID:jgera,项目名称:AutonomousCar,代码行数:101,代码来源:Simulation.cs

示例8: ChangeBoard

        /// <summary>
        /// Random grabs or drops a block on the board.
        /// </summary>
        private void ChangeBoard(UpdateArgs args)
        {
            // Loop through the blocks to see if they are too high. If
            // they are, remove them.
            LinkedList<Block> tmpBlocks = new LinkedList<Block>();
            tmpBlocks.AddAll(blocks);

            foreach (Block b in tmpBlocks)
            {
                if (b.BottomPosition > 10)
                {
                    stacks[b].Remove(b);
                    blocks.Remove(b);
                    stacks.Remove(b);
                }
            }

            // Decrement the counter for the timeout
            secondsUntilChange -= args.SecondsSinceLastUpdate;

            if (secondsUntilChange > 0)
                // We aren't changing anything
                return;

            // Reset it
            secondsUntilChange = Entropy.NextDouble() * 2;

            // Pick a random coordinate
            int x = Entropy.Next(0, BoardColumns);
            int y = Entropy.Next(0, BoardRows);
            BlockStack stack = board[x, y];

            // Make sure we aren't already doing something here
            foreach (Block b in blocks)
                if (stacks[b] == stack)
                    // Don't bother this time
                    return;

            // We have a stack, decide if we are going to drop or grab
            // something from the stack.
            bool drop = Entropy.Next(0, 2) == 0;

            if (stack.Count > 5)
                // Don't go over 5 high
                drop = false;

            if (stack.Count == 1)
                // Don't go below 1 high
                drop = true;

            // Figure out what to do
            if (drop)
            {
                // Create a new block
                Block nb = new Block(RandomBlock());
                nb.BottomPosition = 10;
                nb.Vector = Constants.DroppedVector;
                nb.Mass = Constants.BlockMass;
                nb.IsMoving = true;
                nb.CastsShadows = true;
                nb.Height = 1;
                stack.Add(nb);
            }
            else
            {
                // Grab the top block
                Block tb = stack.TopBlock;
                tb.Vector = -Constants.DroppedVector;
                tb.Mass = 0;
                tb.IsMoving = true;
            }
        }
开发者ID:dmoonfire,项目名称:cutegod,代码行数:75,代码来源:MainMenuMode.cs


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