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


C# LinkedList.First方法代码示例

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


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

示例1: ValidateMapping

        private void ValidateMapping(Type service, LinkedList<Type> breadcrumbs)
        {
            if (breadcrumbs.Contains(service))
                throw new CircularDependenciesException(
                    "Found a circular dependency when looking up " + breadcrumbs.First() +
                    ", when inspecting the constructor of " + breadcrumbs.Last() + ", violating service: " + service,
                    breadcrumbs);



            IList<IBuildPlan> buildPlans;
            if (!_serviceMappings.TryGetValue(service, out buildPlans))
                throw new DependencyNotRegisteredException(breadcrumbs.Last.Value, service);

            var cbp = buildPlans.Last() as ConcreteBuildPlan;
            if(cbp == null)
                return;

            breadcrumbs.AddLast(service);
            foreach (var parameter in cbp.Constructor.GetParameters())
            {
                ValidateMapping(parameter.ParameterType, breadcrumbs);
            }
            breadcrumbs.RemoveLast();
        }
开发者ID:adam555,项目名称:Griffin.Container,代码行数:25,代码来源:ContainerBuilder.cs

示例2: resolve

 /// <summary>
 /// 求解
 /// </summary>
 /// <returns></returns>
 public Path resolve()
 {
     Path path = new Path();
       Node start = new Node(p.Start);
       LinkedList<Node> Open = new LinkedList<Node>();
       HashSet <Node>Open2=new HashSet<Node> ();  // 元素与Open一样。效率不同。
       HashSet<Node> Close = new HashSet<Node>();
       Open.AddFirst(start);  // 起始点。
       Open2.Add(start);
       bool flag = false;
       Node curr=null;
       while(Open .Count >0)
       {
       curr = Open.First();  // 取出第一个。
       Open.RemoveFirst();
       Open2.Remove (curr);
       Close.Add(curr);     // 放入闭集合,后面会做重复性检查。
       if (curr.cell.End)
       {
           flag = true;
           break;
       }
       curr.Expand(Open, Open2, Close); //展开此节点:其所有的不在Open和Close的子节点,加入到队列尾部。
       }
       if (flag)
       {
      while(curr.Parent !=null)//记录下所有的结果。
      {
          path.cells.Add(curr.cell);
          curr = curr.Parent;
      }
      path.cells.Add(curr.cell);//这是第一个点。
       }
       return path;
 }
开发者ID:shihang0001,项目名称:technology-program-puzzle,代码行数:39,代码来源:BDF.cs

示例3: Planet

        /// <summary>
        /// Initializes Mogre properties, runtime Properties (Speed, Rotate - speed of rotation,
        /// PickUp - pick up distance). Needs 3 arguments and fourth is optional (name of a mesh,
        /// string with position - Vector2 converted to Vector3, distance from center and health).
        /// </summary>
        /// <param name="name">The name of the planet.</param>
        /// <param name="myTeam">The planet team.</param>
        /// <param name="args">The array with arguments (3 required + 1 optional)</param>
        public Planet(string name, Team myTeam, object[] args)
        {
            this.name = name;
            this.mesh = (string)args[1];
            this.team = myTeam;

            this.position = new Property<Vector3>(Vector3.ZERO);

            SetProperty(PropertyEnum.Position, this.position);
            base.SetProperty(PropertyEnum.Speed, Game.PropertyManager.GetProperty<float>("speed3"));
            base.SetProperty(PropertyEnum.Position, position);
            base.SetProperty(PropertyEnum.Rotate, Game.PropertyManager.GetProperty<float>("planetRotateSpeed"));
            base.SetProperty(PropertyEnum.PickUp, Game.PropertyManager.GetProperty<float>("planetPickUpDistance"));

            if (args.Count() == 4) {
                setHp(Convert.ToInt32(args[3]));
            }

            var planetPosition = ParseStringToVector3((string)args[0]);
            centerPosition = ParseStringToVector3((string)args[2]);

            // Prepare list of positions
            circularPositions = CalculatePositions(circularNum, CalculateDistance(planetPosition, centerPosition), centerPosition);

            // Sets start position
            SetStartPosition(circularNum, planetPosition);

            position.Value = circularPositions.First();

            // Mogre inicialization of object
            entity = Game.SceneManager.CreateEntity(name, mesh);
        }
开发者ID:vavrekmichal,项目名称:StrategyGame,代码行数:40,代码来源:Planet.cs

示例4: foreach

        static int NumAños(Relación[] lista, int N, int víctima) {
            LinkedList<Relación> cola = new LinkedList<Relación>();
            int[] veces = Enumerable.Range(0, N).Select(x => 0).ToArray();
            Relación aux;

            foreach(Relación x in Conjunto(lista, víctima)) {
                cola.AddLast(x);
            }
            veces[víctima - 1] = 1;
            //Console.WriteLine("V: " + veces.Select(x => x.ToString())
            //                               .Aggregate((x, xs) => x + " " + xs));

            while(cola.Count() > 0) {
                aux = cola.First();
                cola.RemoveFirst();
                veces[aux.necesita - 1] = veces[aux.asignatura - 1] + 1;
                //Console.WriteLine("Asig: " + aux.asignatura + " Nece: " + aux.necesita);
                //Console.WriteLine("V: " + veces.Select(x => x.ToString())
                //                               .Aggregate((x, xs) => x + " " + xs));
                foreach(Relación x in Conjunto(lista, aux.necesita)) {
                    cola.AddLast(x);
                }
            }

            return veces.Max();
        }
开发者ID:gorkinovich,项目名称:MTP,代码行数:26,代码来源:Ejercicio107.cs

示例5: Bfs

        /// <summary>
        ///
        /// </summary>
        /// <param name="s"></param>
        /// <param name="t"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public bool Bfs(int s, int t, int[] parent)
        {
            PopulateListNodeVisited();

            LinkedList<int> queue = new LinkedList<int>();
            queue.AddLast(s);
            Visited[s] = true;
            parent[s] = -1;

            // Standard BFS Loop
            while (queue.Count() != 0)
            {
                int u = queue.First();
                queue.RemoveFirst();

                for (int v = 0; v < NumberOfNodes; v++)
                {
                    if ((Visited[v] == false) && (PathTwoDimensionArray[u, v] > 0))
                    {
                        queue.AddLast(v);
                        parent[v] = u;
                        Visited[v] = true;
                    }
                }
            }
            return (Visited[t] == true);
        }
开发者ID:looping42,项目名称:Framework,代码行数:34,代码来源:FordFulkerson.cs

示例6: AssetSimulated

        /**
         * Create a simulated asset from a real one.
         * It extract the name of real asset for "fake" one
         * and the first price (at first date) and simulate
         * at all dates from dates_simul.
         * 
         * getPrice(t) with t from dates_simul will then return
         * a simulated price
         * getPrice(t) with t before first date from dates_simul
         * will return real price of asset
         * getPrice(t) with all others date will throw exception
         **/
        public AssetSimulated(IAsset real, LinkedList<DateTime> dates_simul, RandomNormal rand)
        {
            this.real = real;
            prices = new Dictionary<DateTime, double>();
            first_date = dates_simul.First();
            r = 0.04;
                //real.getCurrency().getInterestRate(first_date, TimeSpan.Zero);
            // TODO
            //sigma = real.getVolatility(first_date);
            sigma = 0.2;

            // debug kevin
            double St = 75 + 50*rand.NextDouble();
            DateTime lastDate = first_date;
            //double S0 = real.getPrice(first_date);
            int i = 0;
            foreach (DateTime date in dates_simul)
            {
                double T = (date - lastDate).TotalDays / 365; // time in year
                double WT = Math.Sqrt(T) * rand.NextNormal();
                St = St * Math.Exp((r - sigma * sigma / 2) * T + sigma * WT);
                prices[date] = St;
                lastDate = date;
                i++;
            }
        }
开发者ID:bonkoskk,项目名称:peps,代码行数:38,代码来源:AssetSimulated.cs

示例7: tan

 private static Node tan(LinkedList<Node> parameters)
 {
     if (parameters.Count != 1)
         throw new Exception("Wrong number of parameters");
     //Use a numerics library that can do decimal type math
     return new NumberNode((decimal)Math.Tan((double)parameters.First().GetValue().AsDecimal()));
 }
开发者ID:Amichai,项目名称:OpenPadProject,代码行数:7,代码来源:CompilerRules.cs

示例8: checkHouse

 private static void checkHouse(LinkedList<Skeleton> moves)
 {
     if (!canGesture)
         return;
     Joint rightHand = moves.First<Skeleton>().Joints[JointType.HandRight];
     Joint leftHand = moves.First<Skeleton>().Joints[JointType.HandLeft];
     Joint head = moves.First<Skeleton>().Joints[JointType.Head];
     if (rightHand.Position.Y > head.Position.Y && leftHand.Position.Y > head.Position.Y)
     {
         if (Math.Abs(rightHand.Position.X - leftHand.Position.X) < .2)
         {
             canGesture = false;
             lastGesture = "House";
             canGestureTimer.Start();
         }
     }
 }
开发者ID:kennydo,项目名称:Choreoh,代码行数:17,代码来源:Global.cs

示例9: checkInitialize

 private static void checkInitialize(LinkedList<Skeleton> moves)
 {
     if (!canGesture)
         return;
     Joint rightHand = moves.First<Skeleton>().Joints[JointType.HandRight];
     Joint leftHand = moves.First<Skeleton>().Joints[JointType.HandLeft];
     Joint head = moves.First<Skeleton>().Joints[JointType.Head];
     if (rightHand.Position.Y > .05 + head.Position.Y && leftHand.Position.Y > .05 + head.Position.Y)
     {
         if (Math.Abs(rightHand.Position.X - leftHand.Position.X) > .3)
         {
             initPos = !initPos;
             canGesture = false;
             lastGesture = "Initialized";
             canGestureTimer.Start();
         }
     }
 }
开发者ID:jschadlick,项目名称:Choreoh,代码行数:18,代码来源:Global.cs

示例10: ResourceBuilding

 /// <summary>
 /// Constructs a new ResourceBuilding
 /// </summary>
 /// <param name="name"></param>
 /// <param name="posX"></param>
 /// <param name="posY"></param>
 /// <param name="maxHealth"></param>
 /// <param name="owner"></param>
 /// <param name="baseBuilding"></param>
 public ResourceBuilding(String name, int posX, int posY,
     Player owner, BaseBuilding baseBuilding, LinkedList<Tile> controlZone)
     : base(name, posX, posY, RESOURCE_BUILDING_HEALTH, owner, Globals.BuildingTypes.Resource, baseBuilding,controlZone)
 {
     this.rateOfProduction = controlZone.First().GetTerrainType().getResourceModifier() + DEFAULT_PRODUCTION;
     if (baseBuilding != null)
     {
         baseBuilding.RateOfProduction += this.rateOfProduction;
     }
 }
开发者ID:squid-box,项目名称:Breensoft-ReCellection,代码行数:19,代码来源:ResourceBuilding.cs

示例11: Main2

        static void Main2(string[] args)
        {
            double purgeThreshold = .7;
            InputLoader loader = new InputLoader();
            loader.LoadFile("digits.csv");
            StreamProcessor processor = new StreamProcessor(28,28);
            //var count = processor.AddContextFeautres();
            //Debug.Print(count.ToString() + " context features added.");
            processor.GenerateRandomFeatures(1150);
            LinkedList<bool> rollingRightWrong = new LinkedList<bool>();
            int thresholdIdx = 2;
            int correct = 0;
            int i = 1;
            //for (int i = 1; i < 25000; i++) {
            while(true){
                i = i % 25000;

                //Debug.Print(i.ToString());
                Label l;
                var a = loader.AccessElement(i, out l);
                processor.SetNextFeautreContext(a, l);
                var output = processor.Predict();
                processor.Train();
                var best = output.BestResult();
                if (best != null && best.Item2 != 0) {
                    //Debug.Print(i.ToString() + "  " +
                    //    best.Item1.TextRepresentation + " "
                    //    + best.Item2.ToString());
                    //Debug.Print("Desired: " + processor.DataLabel.TextRepresentation);
                    bool guessedRight = processor.DataLabel.TextRepresentation == best.Item1.TextRepresentation;
                    rollingRightWrong.AddLast(guessedRight);
                    if (guessedRight) {
                        correct++;
                    }
                    if (rollingRightWrong.Count() > 100) {
                        if (rollingRightWrong.First()) {
                            correct--;
                        } rollingRightWrong.RemoveFirst();
                    }

                }

                //if(processor.PurgeFeautres(purgeThreshold) > 1000) purgeThreshold+= .01;
                if (i % 400 == 0) {

                    Debug.Print("Idx: " + i.ToString() + " " + ((double)correct / 100).ToString());
                    processor.PrintUtil(thresholdIdx);
                    thresholdIdx += 2;
                    //string output2 = processor.DescribeAllFeatures();
                    //Debug.Print(output2);
                }
                i++;
            }
            //Get the ability to quickly serialize good heuristics for the future
        }
开发者ID:Amichai,项目名称:DataAnalysis,代码行数:55,代码来源:Program.cs

示例12: DFS

        private static int DFS(IList<ElementId> columnIds, IList<ElementId> beamIds, out int num_IndividualColumn)
        {
            num_IndividualColumn = 0;
            List<Element> columns = (new FilteredElementCollector(_doc, columnIds)).OfClass(typeof(FamilyInstance)).ToList();
            List<Element> beams = (new FilteredElementCollector(_doc, beamIds)).OfClass(typeof(FamilyInstance)).ToList();
            int k = 0;
            LinkedList<Element> open = new LinkedList<Element>();
            HashSet<ElementId> discovered = new HashSet<ElementId>();
            foreach(Element column in columns)
            {
                if (!discovered.Contains(column.Id))
                {
                    ++k;
                    open.AddFirst(column);
                    discovered.Add(column.Id);
                    while (open.Count != 0)
                    {
                        Element e = open.First();
                        open.RemoveFirst();
                        BoundingBoxXYZ bbXYZ = e.get_BoundingBox(_doc.ActiveView);
                        XYZ deltaXYZ = new XYZ(ErrorCTRL_BB, ErrorCTRL_BB, _maxBB.Max.Z);
                        BoundingBoxIntersectsFilter bbFilter = new BoundingBoxIntersectsFilter(new Outline(bbXYZ.Min - deltaXYZ, bbXYZ.Max + deltaXYZ));
                        FilteredElementCollector fec = null;
                        if (((FamilyInstance)e).StructuralUsage == StructuralInstanceUsage.Column)
                        {
                            fec = new FilteredElementCollector(_doc, beamIds);
                            fec.WherePasses(bbFilter);
                            if (fec.Count() == 0)
                            {
                                ++num_IndividualColumn;
                                --k;
                            }
                        }
                        else
                        {
                            fec = new FilteredElementCollector(_doc, columnIds);
                            fec.WherePasses(bbFilter);
                        }

                        foreach (Element intersectedEle in fec)
                        {
                            if (!discovered.Contains(intersectedEle.Id))
                            {
                                open.AddFirst(intersectedEle);
                                discovered.Add(intersectedEle.Id);
                            }
                        }
                    }
                }
            }
            return k;
        }
开发者ID:Xiang-Zeng,项目名称:P58_Loss,代码行数:52,代码来源:PBracedFrame.cs

示例13: recursion_DFS_backtracking

        /*
         * source code from blog:
         * https://github.com/zwxxx/LeetCode/blob/master/Sudoku_Solver.cpp
         * convert it to C#
         *
         * julia's comment:
         * 1. find C# class similar to C++ list
         * http://stackoverflow.com/questions/6320622/does-c-have-anything-like-liststring-in-c
         *   use LinkedList class
         * 2. Add all blank nodes to a LinkedList, so it is easy to manipulate the list.
         *    record the number as one integer, value = row * 9 + col
         */
        protected static bool recursion_DFS_backtracking(char[][] board, LinkedList<Int16> blank)
        {
            if (blank.Count ==0) {
                return true;
            }

            int cell = (Int16)blank.First();

            int x = cell / 9, y = cell % 9;

            bool[] available = new bool[10];

            for (int i = 1; i <= 9; i++) {
                available[i] = true;
            }

            for (int i = 0; i < 9; i++) {
                if (board[i][y] != '.') {
                    available[board[i][y] - '0'] = false;
                }
                if (board[x][i] != '.') {
                    available[board[x][i] - '0'] = false;
                }
            }

            for (int i = 0, mx = x / 3 * 3, my = y / 3 * 3; i < 3; i++) {
                for (int j = 0; j < 3; j++) {
                    if (board[mx + i][my + j] != '.') {
                        available[board[mx + i][my + j] - '0'] = false;
                    }
                }
            }

            for (int i = 1; i <= 9; i++) {
                if (available[i]) {
                    blank.RemoveFirst();

                    board[x][y] = (char)('0' + i);

                    if (recursion_DFS_backtracking(board, blank)) {
                        return true;
                    }

                    blank.AddFirst(Convert.ToInt16(cell));

                    board[x][y] = '.';
                }
            }

            return false;
        }
开发者ID:jianminchen,项目名称:sudokuSolver,代码行数:63,代码来源:Program5.cs

示例14: Run

 public static void Run()
 {
     using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
     using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
     {
         int n = fs.NextInt();
         LinkedList<int>[] adjList = new LinkedList<int>[n];
         int[] p = new int[n];
         for (int i = 0; i < n; i++)
         {
             adjList[i] = new LinkedList<int>();
         }
         for (int u = 0; u < n; u++)
         {
             int v = fs.NextInt() - 1;
             p[u] = v;
             adjList[u].AddLast(v);
             if (u != v) adjList[v].AddLast(u);
         }
         LinkedList<int> comps = new LinkedList<int>();
         bool[] visited = new bool[n];
         for (int u = 0; u < n; u++)
         {
             if (!visited[u]) 
             {
                 int r = -1;
                 DoDfs(u, adjList, visited, p, -1, ref r);
                 comps.AddLast(r);
             }
         }
         int k = comps.Count - 1;
         int root = comps.Where(u => u == p[u]).DefaultIfEmpty(-1).First();
         if (root == -1) 
         {
             root = comps.First();
             p[root] = root;
             k++;
         }
         foreach (int u in comps)
         {
             if (u != root) p[u] = root;
         }
         writer.WriteLine(k);
         for (int i = 0; i < n; i++)
         {
             writer.Write(p[i] + 1 + " ");
         }
     }
 }
开发者ID:dzholmukhanov,项目名称:AlgorithmTraining,代码行数:49,代码来源:FixaTree363.cs

示例15: FullyRefine

        public void FullyRefine(ref LinkedList<Primitive> refined)
        {
            LinkedList<Primitive> todo = new LinkedList<Primitive>();
            todo.AddLast(this);
            while (todo.Count() > 0)
            {
                // Refine last primitive in todo list
                Primitive prim = todo.First();
                todo.RemoveFirst();

                if (prim.CanIntersect())
                    refined.AddLast(prim);
                else
                    prim.Refine(ref todo);
            }
        }
开发者ID:dipankarbd,项目名称:mypersonaltestproject00001,代码行数:16,代码来源:Primitive.cs


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