Example #1
0
        public static void Main(string[] args)
        {
            ResearchTeamCollection l = new ResearchTeamCollection();

            l.AddDefaults();
            l.AddDefaults();
            l.AddDefaults();
            ResearchTeam team1 = new ResearchTeam("one", "name", 12, TimeFrame.TwoYears);

            l.AddResearchTeams(team1);

            l.Sort(1);
            l.Sort(2);
            l.Sort(3);

            Console.WriteLine("\n\nMin item: {0}", l.MinRegNum);
            foreach (ResearchTeam team in l.TwoYearsTeams)
            {
                Console.WriteLine("2Years: {0}", team);
            }
            foreach (ResearchTeam team in l.NGroup(0))
            {
                Console.WriteLine("Group: {0}", team);
            }


            TestCollection test = new TestCollection();

            test.GetTiming();
        }
Example #2
0
 public void AddDefaults(int n)
 {
     for (int i = 0; i < n; i++)
     {
         ResearchTeam tTeam = new ResearchTeam("A" + i, "C" + i, i, "T" + i, TimeFrame.Long);
         resTeamDict.Add(KeySelector.Invoke(tTeam), tTeam);
     }
 }
Example #3
0
 public TestCollections(int elementsCount)
 {
     foreach (var num in Enumerable.Range(1, elementsCount).RandomShuffle())
     {
         ResearchTeam newObject = GenElement(num);
         teamList.Add(newObject.Team);
         strList.Add(newObject.Name);
         resTeamDict.Add(newObject.Team, newObject);
         resTeamDict2.Add(newObject.Name, newObject);
     }
 }
Example #4
0
        public static ResearchTeam GenElement(int num)
        {
            var result = new ResearchTeam("ResName" + num, "CompName" + num, num, "TeamName" + num, TimeFrame.Long);

            int artNum = new Random(Seed: DateTime.Now.Millisecond).Next(10);

            for (int i = 0; i < artNum; i++)
            {
                result.AddPapers(new Paper("ArtName" + num, new Person("Author" + num, "Surname" + num, new DateTime(2000, 1, 1)), new DateTime(2020, 10, 10)));
            }

            return(result);
        }
Example #5
0
        public static void Main()
        {
            ResearchTeamCollection <string> researchTeamCollection = new ResearchTeamCollection <string>(team => team.Name);

            researchTeamCollection.AddDefaults(10);

            var testResTeam1 = new ResearchTeam("ResName***", "CompName***", 912, "Teammy", TimeFrame.TwoYears);
            var testResTeam2 = new ResearchTeam("ResName___", "CompName___", 912, "Turner", TimeFrame.TwoYears);

            testResTeam1.AddPapers(new Paper("B", new Person("Andrew", "Garfield", new DateTime(1985, 1, 21)), new DateTime(2020, 1, 10)));
            testResTeam1.AddPapers(new Paper("C", new Person("Santa", "Claus", new DateTime(1985, 1, 21)), new DateTime(2019, 1, 10)));
            testResTeam1.AddPapers(new Paper("A", new Person("Pavel", "Morozov", new DateTime(1985, 1, 21)), new DateTime(2018, 1, 10)));

            testResTeam2.AddPapers(new Paper("A", new Person(), new DateTime(2021, 2, 6)));
            testResTeam2.AddPapers(new Paper("A", new Person(), new DateTime(2019, 2, 6)));
            testResTeam2.AddPapers(new Paper("A", new Person(), new DateTime(2018, 2, 6)));

            researchTeamCollection.AddResearchTeams(testResTeam1, testResTeam2);

            //1
            Console.WriteLine("Статьи отсортированные по дате: ");
            foreach (var item in testResTeam1.SortArticlesByDate())
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nСтатьи отсортированы по названию: ");
            foreach (var item in testResTeam1.SortByArticleName())
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nСтатьи отсортированы по фамилии автора: ");
            foreach (var item in testResTeam1.SortByAuthorSurname())
            {
                Console.WriteLine(item);
            }
            //2

            var tTeam1 = new ResearchTeam("OOO", "Comp___Name", 122, "Troover", TimeFrame.Year);
            var tTeam2 = new ResearchTeam("FFF", "Comp_-_Name", 93, "CatDog", TimeFrame.Year);

            tTeam1.AddPapers(new Paper("FirstPaper", new Person("Andrew", "Garfield", new DateTime(1985, 1, 21)), new DateTime(2020, 5, 10)));

            tTeam2.AddPapers(new Paper("SecondPaper", new Person(), new DateTime(2021, 1, 6)));

            ResearchTeamCollection <string> strTeamCollection = new ResearchTeamCollection <string>(team => team.Name);

            strTeamCollection.AddResearchTeams(tTeam1, tTeam2, testResTeam1, testResTeam2);

            Console.WriteLine("\nResTeam<string>:");
            Console.WriteLine(strTeamCollection);

            //3
            Console.WriteLine("Дата выхода последней статьи");
            Console.WriteLine(strTeamCollection.LatestArticleDate);

            Console.WriteLine("\nКоманды с продолжительностью исследования год:");
            foreach (var item in strTeamCollection.TimeFrameGroup(TimeFrame.Year))
            {
                Console.WriteLine(item.Value.ToShortString());
            }

            Console.WriteLine("\nГруппировка элементов по длительности исследований: ");
            foreach (var group in strTeamCollection.DurationGroups)
            {
                Console.WriteLine("\nГруппа с продолжительностью " + group.Key);
                foreach (var item in group)
                {
                    Console.WriteLine(item.Value.ToShortString());
                }
            }
            //4
            int elCount = 0;// = 1000000;

            while (true)
            {
                try
                {
                    Console.Write("Введите кол-во элементов: ");
                    elCount = Int32.Parse(Console.ReadLine());

                    if (elCount <= 0)
                    {
                        Console.WriteLine("Число должно быть положительным! Повторите ввод");
                        continue;
                    }

                    break;
                }
                catch (FormatException)
                {
                    Console.WriteLine("Ошибка при вводе числа! Повторите ввод");
                }
                catch (OverflowException)
                {
                    Console.WriteLine("Число слишком большое! Повторите ввод");
                }
            }

            TestCollections testCollection = new TestCollections(elCount);
            List <Team>     lst            = testCollection.GetTeamList();

            Console.WriteLine("\nВремя для первого элемента: \n");
            PrintTime(lst[0], testCollection);

            Console.WriteLine("\nВремя для элемента в середине: \n");
            PrintTime(lst[lst.Count / 2], testCollection);

            Console.WriteLine("\nВремя для элемента в конце: \n");
            PrintTime(lst[lst.Count - 1], testCollection);

            Console.WriteLine("\nВремя для элемента которого нет: \n");
            PrintTime(new Team("GG", 123321, "321"), testCollection);
        }
Example #6
0
        public int GetTiming()
        {
            SetDefaults();
            Console.WriteLine("\n\n--------List-------\n");
            Team team      = this[0];
            var  taskBegin = Environment.TickCount;

            _a.Contains(team);
            var taskEnd = Environment.TickCount;

            Console.WriteLine("\nSearch for first: {0}", taskEnd - taskBegin);

            team      = this[1];
            taskBegin = Environment.TickCount;
            _a.Contains(team);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for second: {0}", taskEnd - taskBegin);

            team      = this[2];
            taskBegin = Environment.TickCount;
            _a.Contains(team);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for third: {0}", taskEnd - taskBegin);

            team      = this[3];
            taskBegin = Environment.TickCount;
            _a.Contains(team);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for fourth: {0}", taskEnd - taskBegin);


            Console.WriteLine("\n\n----Dictionary Keys----\n");
            Team[] keys = new Team[4];
            _c.Keys.CopyTo(keys, 0);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[0]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for first: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[1]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for second: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[2]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for third: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[3]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for fourth: {0}", taskEnd - taskBegin);


            Console.WriteLine("\n\n----Dictionary Values----\n");
            ResearchTeam[] values = new ResearchTeam[4];
            _c.Values.CopyTo(values, 0);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[0]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for first: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[1]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for second: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[2]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for third: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[3]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for fourth: {0}", taskEnd - taskBegin);



            return(0);
        }