コード例 #1
0
        static void Main(string[] args)
        {
            int       v  = 1000000000;
            int       n  = 2 * 100000;
            int       i  = 20000;
            Stopwatch sw = new Stopwatch();


            Console.WriteLine("stack with dynamic list:");
            Console.WriteLine("adding " + n.ToString() + " element :");
            sw.Start();
            for (int j = 0; j < n; j++)
            {
                Stack.push(v);
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
            sw.Reset();

            Console.WriteLine("adding v to the first " + i.ToString() + " elements 10000 times");
            sw.Start();
            for (int j = 0; j < 10000; j++)
            {
                Stack.inc(i, v);
                //Console.WriteLine(i);
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);


            Console.WriteLine("stack with linked list:");
            Console.WriteLine("adding " + n.ToString() + " element :");
            sw.Reset();
            sw.Start();
            for (int j = 0; j < n; j++)
            {
                Lin_List_Stack.push(v);
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);

            sw.Reset();
            Console.WriteLine("adding v to the first " + i.ToString() + " elements 10000 times");
            sw.Start();
            for (int j = 0; j < 10000; j++)
            {
                Lin_List_Stack.inc(i, v);
                //Console.WriteLine(i);
            }
            sw.Stop();
            Console.WriteLine(sw.Elapsed);

            Console.WriteLine(Global.x);
            Console.ReadKey();
        }
コード例 #2
0
 public static void pop()
 {
     if (first == null && last == null)
     {
         Console.WriteLine("EMPTY");
     }
     else
     {
         first      = first.next;
         first.prev = null;
         Lin_List_Stack.returntop();
     }
 }