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


C# LinkedList.Count方法代码示例

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


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

示例1: CountLinkedList

        private static void CountLinkedList(int max)
        {
            WriteLine("Linked lists");

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var ll = new LinkedList<int>();
            for (var i = 0; i < max; i++)
            {
                ll.AddLast(i);
            }
            stopWatch.Stop();
            WriteLine("Time to initialise: " + stopWatch.ElapsedMilliseconds);

            stopWatch.Restart();
            WriteLine(ll.Count);
            stopWatch.Stop();
            WriteLine("Time to count with prop: " + stopWatch.ElapsedMilliseconds);

            stopWatch.Restart();
            WriteLine(ll.Count());
            stopWatch.Stop();
            WriteLine("Time to count with extension method: " + stopWatch.ElapsedMilliseconds);

            WriteLine();
        }
开发者ID:robert-impey,项目名称:CodingExperiments,代码行数:27,代码来源:Program.cs

示例2: 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

示例3: 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

示例4: 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

示例5: Update

	public void Update()
	{
		//remove any followers that didn't renew their follow status
		var currentFollowers = new LinkedList<int>(followerPositions.Keys);

		foreach (int currentFollower in currentFollowers)
		{
			if (!followRequests.Contains(currentFollower))
			{
				followerPositions.Remove(currentFollower);
			}
			else
			{
				followRequests.Remove(currentFollower);
			}
		}
		
		//update to only include old 
		currentFollowers = new LinkedList<int>(followerPositions.Keys);

		//followRequests now only contains unique new followers
		var newFollowers = new List<int>(followRequests);
		followRequests.Clear();

		/* add new followers alternately to the "left" and "right" (back and front of
		 the list) */
		var newFollowerCount = newFollowers.Count();
		for (int newFollowerIt = 0; newFollowerIt < newFollowerCount; ++newFollowerIt)
		{
			if (newFollowerIt % 2 == 0)
			{
				currentFollowers.AddLast(newFollowers[newFollowerIt]);
			}
			else
			{
				currentFollowers.AddFirst(newFollowers[newFollowerIt]);
			}
		}

		followerPositions = new Dictionary<int, int>();

		var followerIds = currentFollowers.ToArray();
		var count = currentFollowers.Count();
		var halfOffset = count / 2;
		for (int followerIt = 0; followerIt < count; ++followerIt)
		{
			var pos = followerIt - halfOffset;
			if (pos >= 0)
			{
				pos += 1;
			}

			followerPositions.Add(followerIds[followerIt], pos);
		}
	}
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:55,代码来源:FormationManager.cs

示例6: LlenarFormaPago

        public void LlenarFormaPago(){//Carga items de forma de pago
            listaFormaPago = new LinkedList<String>();
            listaFormaPago.AddFirst("Contado");
            listaFormaPago.AddLast("50% anticipo");
            listaFormaPago.AddLast("30 días");
            listaFormaPago.AddLast("Otro");

            for (int x = 0; x < listaFormaPago.Count(); x++){
                comboBox1.Items.Add(listaFormaPago.ElementAt(x).ToString());
            }
        }
开发者ID:fenrrid,项目名称:ProgramVisual,代码行数:11,代码来源:Form2.cs

示例7: LlenarListaProductos

        public void LlenarListaProductos(){//cargar items de productos

            ListaProductos = new LinkedList<String>();
            ListaProductos.AddFirst("computadora");
            ListaProductos.AddLast("calculadora");
            ListaProductos.AddLast("cacahuates");
            ListaProductos.AddLast("carro");

            for (int x = 0; x < ListaProductos.Count(); x++){
                comboBox2.Items.Add(ListaProductos.ElementAt(x).ToString());
            }
        }
开发者ID:fenrrid,项目名称:ProgramVisual,代码行数:12,代码来源:Form2.cs

示例8: Main

        static void Main()
        {
            LinkedList<int> someList = new LinkedList<int>();
            someList.AddFirst(32);
            someList.AddFirst(443);
            someList.AddFirst(23);
            someList.AddFirst(111);
            someList.AddLast(1211);

            Console.WriteLine(someList.Count());

            someList.Remove(23);

            someList.PrintList();
        }
开发者ID:kikooo52,项目名称:C-Programs,代码行数:15,代码来源:TestList.cs

示例9: Main

 public static void Main()
 {
     // Create LinkedList and test its methods
     ListItem<int> lastElement = new ListItem<int>(5);
     LinkedList<int> linkedList = new LinkedList<int>(lastElement);
     ListItem<int> middleElement = new ListItem<int>(2);
     linkedList.Add(middleElement);
     ListItem<int> firstElement = new ListItem<int>(-3);
     linkedList.Add(firstElement);
     bool contains = linkedList.Contains(firstElement);
     linkedList.Remove(middleElement);
     int index = linkedList.IndexOf(lastElement);
     int count = linkedList.Count();
     ListItem<int> element = linkedList[index];
     bool isSame = lastElement == element;
 }
开发者ID:vasilkrvasilev,项目名称:DataStructuresAlgorithms,代码行数:16,代码来源:Example.cs

示例10: 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

示例11: Main

        public static void Main()
        {
            LinkedList<int> testLinkedList = new LinkedList<int>();

            testLinkedList.AddFirst(5);
            testLinkedList.AddFirst(4);
            testLinkedList.AddLast(6);
            testLinkedList.AddLast(7);
            testLinkedList.RemoveFirst();
            testLinkedList.RemoveLast();

            foreach (var item in testLinkedList)
            {
                Console.WriteLine("Item value: {0}", item);
            }

            Console.WriteLine("Linked list items count: {0}", testLinkedList.Count());
        }
开发者ID:baretata,项目名称:CSharpDSA,代码行数:18,代码来源:MainProgram.cs

示例12: Main

        static void Main(string[] args)
        {
            LinkedList<int> list = new LinkedList<int>();

            list.AddLast(7);
            list.AddLast(3);
            list.AddLast(78);
            list.AddLast(96);
            list.AddLast(1);
            list.AddLast(5);
            list.AddLast(9);
            list.AddLast(52);
            list.AddLast(67);
            list.AddLast(91);
            list.AddLast(55);

            Console.WriteLine(list.ElementAt(list.Count() - pos));
        }
开发者ID:neoleohs,项目名称:TakeHomeTest,代码行数:18,代码来源:Program.cs

示例13: getAssignmentList

        public LinkedList<Paper> getAssignmentList()
        {
            LinkedList<Paper> AssignmentsList = new LinkedList<Paper>();

                CloudBlobContainer blobContainer = null;
                CloudStorageAccount storageAccount = null;
                CloudBlobClient blobClient = null;

                storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
                blobClient = storageAccount.CreateCloudBlobClient();

                blobContainer = blobClient.GetContainerReference("gallery"); //Gets the blobe storage
                var blobs = blobContainer.ListBlobs(); //Gets the entire list of Blob items
                var blobList = new List<string>();
                foreach (var blob in blobs)
                {
                    Paper newPaper = new Paper();
                    var srcBlob = blobContainer.GetBlobReference(blob.Uri.ToString()); //Gets each blobs Uri
                    srcBlob.FetchAttributes();
                    txtTest.Text = srcBlob.DownloadText();
                    blobList.Add(blob.Uri.ToString());

                    String fileDL = srcBlob.DownloadText();
                    LinkedList<String> dataList = new LinkedList<string>();
                    //string[] lines = fileDL.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); //Splits file up by '\n'
                    string[] lines = fileDL.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); //Splits file up by '\n'
                    for (int i = 0; i < lines.Length; i++)
                        dataList.AddLast(lines[i].ToString());
                    newPaper.Data = dataList;
                    newPaper.Link = srcBlob.Metadata.Get("LinkID");
                    newPaper.AID = srcBlob.Metadata.Get("AssignID");
                    newPaper.UserID = srcBlob.Metadata.Get("UserID");
                    newPaper.FileName = srcBlob.Metadata.Get("FileName");

                        AssignmentsList.AddFirst(newPaper);
                }
                   lblInfo.Text = (AssignmentsList.Count().ToString());
                    RefreshGallery();

                    return AssignmentsList;
        }
开发者ID:cweber-wou,项目名称:capstone,代码行数:41,代码来源:Default.aspx.cs

示例14: hit_ground

        public bool hit_ground(Vector2 position, LinkedList<Stage> stages)
        {
            //Color[] collisionColor = new Color[screenHeight * screenWidth];
            for (int i = 0; i < stages.Count(); i++)
            {
                int shiftedX = (int)position.X - (int)stages.ElementAt(i).position.X;
                if (shiftedX > 0 && shiftedX < stages.ElementAt(i).width &&
                    position.Y < stages.ElementAt(i).height && position.Y > 0)
                {
                    //stages.ElementAt(i).cm.GetData<Color>(0, new Rectangle(shiftedX, (int)position.Y, 2, 2), collisionColor, 0, 4);
                    //stages.ElementAt(i).cm.GetData<Color>(collisionColor, shiftedX + ((int)position.Y * screenWidth), 1);
                    //stages.ElementAt(i).cm.GetData<Color>(collisionColor);

                    if (stages.ElementAt(i).collisionColor[shiftedX + ((int)position.Y * stages.ElementAt(i).width)] == Color.Black)
                    {
                        return true;
                    }
                }
            }
            return false;
        }
开发者ID:epolekoff,项目名称:SynesthesiaChaos,代码行数:21,代码来源:Movable.cs

示例15: Main

        public static void Main()
        {
            LinkedList<int> test = new LinkedList<int>();

            test.AddFirst(3);
            test.AddFirst(2);
            test.AddLast(1);
            test.AddLast(4);
            test.RemoveFirst();
            test.RemoveLast();

            var index = 1;

            foreach (var item in test)
            {
                Console.WriteLine("Item #{0}: {1}", index, item);
                index++;
            }

            Console.WriteLine("LinkedList.Count: {0}", test.Count());
        }
开发者ID:NikitoG,项目名称:TelerikAcademyHomeworks,代码行数:21,代码来源:Startup.cs


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