Ejemplo n.º 1
0
        private static void Main()
        {
            var list = new SinglyLinkedListGeneric <Person>();

            list.AddRange(new[]
            {
                new Person {
                    FirstName = "Hans", LastName = "Muster"
                },
                new Person {
                    FirstName = "Peter", LastName = "Schmidt"
                },
                new Person {
                    FirstName = "Berta", LastName = "Müller"
                },
                new Person {
                    FirstName = "Hermann", LastName = "Schulze"
                },
            });

            foreach (var p in list)
            {
                Console.WriteLine(p.FirstName + " " + p.LastName);
                if (p.LastName.StartsWith("M"))
                {
                    list.Remove(p);
                }
            }

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            var count       = 0;
            var argsCorrect = args.Length > 0 && int.TryParse(args[0], out count);

            if (!argsCorrect)
            {
                Console.WriteLine("Aufruf: ProfileMethods <AnzahlDurchläufe>\nBeispiel: ProfileMethods 10000");
                return;
            }
            var profiler = new Profiler(count);

            var arrayList        = new ArrayList <int>();
            var linkedList       = new SinglyLinkedListGeneric <int>();
            var arrayListSystem  = new System.Collections.Generic.List <int>();
            var linkedListSystem = new System.Collections.Generic.LinkedList <int>();

            profiler.AddMethod(arrayList, "Add", true);
            profiler.AddMethod(arrayList, "Remove", true);
            profiler.AddMethod(linkedList, "Add", true);
            profiler.AddMethod(linkedList, "Remove", true);
            profiler.AddMethod(arrayListSystem, "Add", true);
            profiler.AddMethod(arrayListSystem, "Remove", true);
            profiler.AddMethod(linkedListSystem, "AddLast", true);
            profiler.AddMethod(linkedListSystem, "RemoveLast", true);
            profiler.AddMethod(arrayList, "Add", false);
            profiler.AddMethod(arrayList, "RemoveAt", true);
            profiler.AddMethod(arrayListSystem, "Add", false);
            profiler.AddMethod(arrayListSystem, "RemoveAt", true);

            //profiler.AddMethod(arrayList,        "Add",     false);
            //profiler.AddMethod(arrayList,        "IndexOf", true);
            //profiler.AddMethod(arrayListSystem,  "Add",     false);
            //profiler.AddMethod(arrayListSystem,  "IndexOf", true);
            //profiler.AddMethod(linkedList,       "Add",     false);
            //profiler.AddMethod(linkedList,       "Contains", true);
            //profiler.AddMethod(linkedListSystem, "AddLast",  false);
            //profiler.AddMethod(linkedListSystem, "Contains", true);

            profiler.Run();
            Console.ReadLine();
        }