Exemplo n.º 1
0
        static void Main(string[] args)
        {
            forLabFour();
            ResearchTeamCollection a = new ResearchTeamCollection();

            List <Person> per  = new List <Person>();
            Person        per1 = new Person();

            per1.Name       = "Kevin";
            per1.Surname    = "Lewin";
            per1.DateOfBorn = DateTime.MinValue;
            per.Add(per1);

            List <Paper> doc  = new List <Paper>();
            Paper        doc1 = new Paper();

            doc1.Autor             = per[0];
            doc1.NameOfPublication = "Some research";
            doc1.Date = DateTime.Now;
            doc.Add(doc1);

            List <Paper> docs2 = new List <Paper>();
            Paper        doc2  = new Paper();

            doc2.Autor             = per[0];
            doc2.NameOfPublication = "Some research";
            doc2.Date = DateTime.Now;
            docs2.Add(doc1);
            docs2.Add(doc2);

            ResearchTeam rt1 = new ResearchTeam();

            rt1.Name      = "Workers";
            rt1.RegNumber = 1;
            foreach (Paper item in docs2)
            {
                rt1.AddPapers(item);
            }

            rt1.Persons = per;

            ResearchTeam rt2 = new ResearchTeam();

            rt2.Name             = "Josefs";
            rt2.RegNumber        = 2;
            rt2.LengthOfResearch = TimeFrame.TwoYears;

            foreach (Paper item in doc)
            {
                rt2.AddPapers(item);
            }
            rt2.Persons = per;

            List <ResearchTeam> t = new List <ResearchTeam> {
                rt1, rt2
            };

            a.AddDefaults(t);

            a.RnameSort();
            Console.WriteLine("Name Sort");
            Console.WriteLine(a.ToString());
            a.RnumSort();
            Console.WriteLine("Registration Number Sort:");
            Console.WriteLine(a.ToString());
            a.DocsSort();
            Console.WriteLine("Docs Sort:");
            Console.WriteLine(a.ToString());
            Console.WriteLine("Min registration number:");
            Console.WriteLine(a.MinRegNum);
            Console.WriteLine("After time Sort:");
            foreach (ResearchTeam h in a.ResLogs)
            {
                Console.WriteLine(h.ToString());
            }
            Console.WriteLine("Group Sort:");
            foreach (ResearchTeam h1 in a.NGroup(1))
            {
                Console.WriteLine(h1.ToString());
            }
            TestCollections test = new TestCollections(1000);

            Console.WriteLine("Search Time:");
            Console.WriteLine(test.GetTime());
            Console.ReadLine();
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Person[] members = new Person[] { new Person("first" + 3, "last" + 3, new DateTime(3 + 1970, 3 % 12, 3 % 27)),
                                              new Person("first" + 2, "last" + 2, new DateTime(2 + 1970, 2 % 12, 2 % 27)),
                                              new Person("first" + 1, "last" + 1, new DateTime(1 + 1970, 1 % 12, 1 % 27)) };
            ResearchTeamCollection researchTeamCollection = new ResearchTeamCollection();

            ResearchTeam[] researchTeams = new ResearchTeam[]
            {
                new ResearchTeam("name" + 3, "study" + 3, 3 + 1, Enums.TimeFrame.Year,
                                 new List <Paper> {
                    new Paper("some" + 3, new Person("first" + 1, "last" + 1, new DateTime(3 + 1970, 3 % 12, 3 % 27)),
                              new DateTime(3 + 1970, 3 % 12, 3 % 27))
                }),
                new ResearchTeam("name" + 1, "study" + 1, 1 + 1, Enums.TimeFrame.TwoYears,
                                 new List <Paper> {
                    new Paper("some" + 1, new Person("first" + 1, "last" + 1, new DateTime(1 + 1970, 1 % 12, 1 % 27)),
                              new DateTime(1 + 1970, 1 % 12, 1 % 27))
                }),
                new ResearchTeam("name" + 50, "study" + 50, 50 + 1, Enums.TimeFrame.Year,
                                 new List <Paper> {
                    new Paper("some" + 50, new Person("first" + 1, "last" + 1, new DateTime(50 + 1970, 50 % 12, 50 % 27)),
                              new DateTime(50 + 1970, 50 % 12, 50 % 27))
                }),
                new ResearchTeam("name" + 21, "study" + 21, 21 + 1, Enums.TimeFrame.Year,
                                 new List <Paper> {
                    new Paper("some" + 21, new Person("first" + 1, "last" + 1, new DateTime(21 + 1970, 21 % 12, 21 % 27)),
                              new DateTime(21 + 1970, 21 % 12, 21 % 27))
                })
            };
            researchTeams[0].Members = members.Skip(2).ToList();
            researchTeams[1].Members = members.Skip(1).ToList();
            researchTeams[2].Members = members.ToList();
            researchTeamCollection.AddResearchTeams(researchTeams);
            Console.WriteLine(researchTeamCollection.ToString());

            researchTeamCollection.SortByRegistrationNumber();
            Console.WriteLine(researchTeamCollection.ToString());

            researchTeamCollection.SortByExploreTheme();
            Console.WriteLine(researchTeamCollection.ToString());

            researchTeamCollection.SortByCountOfPublishing();
            Console.WriteLine(researchTeamCollection.ToString());

            Console.WriteLine(researchTeamCollection.MinRegistryNumber);

            var str = string.Join(Environment.NewLine, researchTeamCollection.GetTwoYearsLongResearchTeams.Select(x => x.ToString()));

            Console.WriteLine(str);

            str = string.Join(Environment.NewLine, researchTeamCollection.NGroup(1).Select(x => x.ToString()));
            Console.WriteLine(str);

            TestCollections testCollections = new TestCollections(2000000);

            testCollections.TestCollectionsProductivity(1);
            testCollections.TestCollectionsProductivity(1000001);
            testCollections.TestCollectionsProductivity(1999999);
            testCollections.TestCollectionsProductivity(20000001);

            Console.ReadKey();
        }