Esempio n. 1
0
        public object Clone()
        {
            var newStack = new EasyStack <T>();

            newStack._items = new List <T>(_items);
            return(newStack);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Model.EasyStack <int> easyStack = new Model.EasyStack <int>();

            easyStack.Push(1);
            easyStack.Push(2);
            easyStack.Push(3);

            var item  = easyStack.Pop();
            var item2 = easyStack.Peek();

            Console.WriteLine(item);
            Console.WriteLine(item2);
            Console.WriteLine();

            var linkedStack = new LinkedStack <int>();

            linkedStack.Push(10);
            linkedStack.Push(20);
            linkedStack.Push(30);
            linkedStack.Push(40);
            linkedStack.Push(50);

            Console.WriteLine(linkedStack.Peek());
            Console.WriteLine(linkedStack.Pop());
            Console.WriteLine(linkedStack.Pop());
            Console.WriteLine(linkedStack.Peek());
            Console.WriteLine();

            var arrayStack = new ArrayStack <int>(5);

            arrayStack.Push(100);
            arrayStack.Push(200);
            arrayStack.Push(300);
            arrayStack.Push(400);

            Console.WriteLine(arrayStack.Peek());
            Console.WriteLine(arrayStack.Pop());
            Console.WriteLine(arrayStack.Pop());
            Console.WriteLine(arrayStack.Peek());
            Console.ReadLine();
        }
Esempio n. 3
0
 public object Clone()
 {
     var newStack = new EasyStack<T>();
     newStack.items = new List<T>(items);
     return newStack;
 }