{"id":5227,"date":"2021-08-03T13:21:54","date_gmt":"2021-08-03T12:21:54","guid":{"rendered":"https:\/\/solidt.eu\/site\/?p=5227"},"modified":"2022-07-25T08:31:28","modified_gmt":"2022-07-25T07:31:28","slug":"c-linkedlist","status":"publish","type":"post","link":"https:\/\/solidt.eu\/site\/c-linkedlist\/","title":{"rendered":"C# LinkedList"},"content":{"rendered":"\n<div style=\"height: 250px; position:relative; margin-bottom: 50px;\" class=\"wp-block-simple-code-block-ace\"><pre class=\"wp-block-simple-code-block-ace\" style=\"position:absolute;top:0;right:0;bottom:0;left:0\" data-mode=\"csharp\" data-theme=\"monokai\" data-fontsize=\"14\" data-lines=\"Infinity\" data-showlines=\"true\" data-copy=\"false\">using System;\nusing System.Collections;\nusing System.Collections.Generic;\nusing System.Diagnostics;\n\nclass Program \n{\n\tstatic void Main (string[] args) \n\t{\n\t\tConsole.WriteLine (\"Hello World!\");\n\n\t\tvar rand = new Random ();\n\t\tvar list = new LinkedList&lt;int> ();\n\t\tvar stack = new Stack&lt;int> ();\n\n\t\tvar sw = new Stopwatch ();\n\n\t\tConsole.Write (\"{0,40}\", \"Pushing to Stack...\");\n\t\tsw.Reset ();\n\t\tsw.Start ();\n\t\tfor (int i = 0; i &lt; 100000; i++) {\n\t\t\tstack.Push (rand.Next ());\n\t\t}\n\t\tsw.Stop ();\n\t\tConsole.WriteLine (\"  Time used: {0,9} ticks\", sw.ElapsedTicks);\n\n\t\tvar nodes = new LinkedListNode&lt;int>[100000];\n\t\tfor (int i = 0; i &lt; 100000; i++) {\n\t\t\tnodes[i] = new LinkedListNode&lt;int> (rand.Next ());\n\t\t}\n\n\t\tConsole.Write (\"{0,40}\", \"Pushing to LinkedList...\");\n\n\t\tsw.Reset ();\n\t\tsw.Start ();\n\t\tfor (int i = 0; i &lt; 100000; i++) {\n\t\t\tlist.AddFirst (nodes[i]);\n\t\t}\n\n\t\tsw.Stop ();\n\t\tConsole.WriteLine (\"  Time used: {0,9} ticks\", sw.ElapsedTicks);\n\t}\n}<\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6,4,1],"tags":[],"class_list":["post-5227","post","type-post","status-publish","format-standard","hentry","category-dotnet","category-programming","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/5227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/comments?post=5227"}],"version-history":[{"count":2,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/5227\/revisions"}],"predecessor-version":[{"id":5935,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/posts\/5227\/revisions\/5935"}],"wp:attachment":[{"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/media?parent=5227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/categories?post=5227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solidt.eu\/site\/wp-json\/wp\/v2\/tags?post=5227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}