static void Main()
        {
            var catCollection = new CatCollection
            {
                new CuteCat {
                    Name = "Pesho"
                },
                new CuteCat {
                    Name = "Ivan"
                }
            };

            foreach (var cats in catCollection)
            {
                Console.WriteLine(cats.Name);
            }

            var coolStack = new CoolStack <int>();

            coolStack.Push(3);
            coolStack.Push(5);
            coolStack.Push(10);
            coolStack.Push(7);
            coolStack.Push(25);
            foreach (var stack in coolStack)
            {
                Console.WriteLine(stack);
            }

            var coolList = new CoolLinkedList <int>();

            coolList.AddHead(1);
            coolList.AddHead(2);
            coolList.AddHead(3);
            coolList.AddHead(4);
            foreach (var i in coolList)
            {
                Console.WriteLine(i);
            }
            SomeMethodsWithParams(1, new[] { "1", "1", "1" });
            SomeMethodsWithParams(2, new[] { "1", "2" });
            SomeMethodsWithParams(3, new[] { "3" });
            SomeMethodsWithParams(5, "3");
            SomeMethodsWithParams(5, "3", "3", "3");
            SomeMethodsWithParams(6, "3", "2", "445");
            SomeMethodsWithParams(6);
        }
Example #2
0
        public static void Main(string[] args)
        {
            var linkedList = new CoolLinkedList();

            linkedList.AddHead(5);
            linkedList.AddHead(10);
            linkedList.AddHead(15);

            // 15 <-> 10 <-> 5

            Console.WriteLine((int)linkedList.Head == 15);
            Console.WriteLine((int)linkedList.Tail == 5);
            Console.WriteLine(linkedList.Count == 3);

            linkedList.AddTail(20);
            linkedList.AddTail(25);

            // 15 <-> 10 <-> 5 <-> 20 <-> 25

            linkedList.ForEach(Console.WriteLine);
            linkedList.ForEach(Console.WriteLine, reverse: true);

            var arr = linkedList.ToArray();

            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine((int)linkedList.Head == 15);
            Console.WriteLine((int)linkedList.Tail == 25);
            Console.WriteLine(linkedList.Count == 5);

            Console.WriteLine((int)linkedList.RemoveHead() == 15);
            Console.WriteLine((int)linkedList.RemoveHead() == 10);
            Console.WriteLine((int)linkedList.Head == 5);
            Console.WriteLine(linkedList.Count == 3);

            //5 <-> 20 <-> 25

            Console.WriteLine(linkedList.Contains(20));
            Console.WriteLine(linkedList.Contains(25));
            Console.WriteLine(linkedList.Contains(2) == false);
            Console.WriteLine((int)linkedList.RemoveTail() == 25);
            Console.WriteLine((int)linkedList.RemoveTail() == 20);
            Console.WriteLine((int)linkedList.RemoveTail() == 5);
            Console.WriteLine(linkedList.Count == 0);

            linkedList.AddTail(5);
            linkedList.AddTail(10);
            linkedList.AddTail(5);
            linkedList.AddTail(20);
            linkedList.AddTail(5);

            //5 <-> 10 <-> 5 <-> 20 <-> 5

            linkedList.Remove(5);

            //10 <-> 20

            Console.WriteLine((int)linkedList.Head == 10);
            Console.WriteLine((int)linkedList.Tail == 20);
            Console.WriteLine(linkedList.Count == 2);

            linkedList.Clear();
            Console.WriteLine(linkedList.Count == 0);
        }