public static GraduateStudet GenerateElement(int i) { GraduateStudet gr = new GraduateStudet(); gr.PersonProperty = new Person(gr.Name, gr.LastName + i, gr.Date); return(gr); }
public void CalculateTime(GraduateStudet g) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); if (PersonList.Contains(g.PersonProperty)) { Console.WriteLine("contains"); } stopWatch.Stop(); TimeSpan ts1d = stopWatch.Elapsed; Console.WriteLine($"Time to find the element in list of persons: {ts1d}"); stopWatch.Start(); if (stringList.Contains(g.PersonProperty.ToString())) { Console.WriteLine("contains"); } stopWatch.Stop(); TimeSpan ts2d = stopWatch.Elapsed; Console.WriteLine($"Time to find the element in list of strings: {ts2d}"); stopWatch.Start(); if (typedKVDictionary.ContainsKey(g.PersonProperty)) { Console.WriteLine("contains"); } stopWatch.Stop(); TimeSpan ts3d = stopWatch.Elapsed; Console.WriteLine($"Time to find the element by key in Dictionary<Person, GraduateStudet>: {ts3d}"); stopWatch.Start(); if (typedKVDictionary.ContainsValue(g)) { Console.WriteLine("contains"); } stopWatch.Stop(); TimeSpan ts4d = stopWatch.Elapsed; Console.WriteLine($"Time to find the element by value in Dictionary<Person, GraduateStudet>: {ts4d}"); stopWatch.Start(); if (typedStringVDictionary.ContainsKey(g.PersonProperty.ToString())) { Console.WriteLine("contains"); } stopWatch.Stop(); TimeSpan ts5d = stopWatch.Elapsed; Console.WriteLine($"Time to find the element by key in Dictionary<string, GraduateStudet>: {ts5d}"); stopWatch.Start(); if (typedStringVDictionary.ContainsValue(g)) { Console.WriteLine("contains"); } stopWatch.Stop(); TimeSpan ts6d = stopWatch.Elapsed; Console.WriteLine($"Time to find the element by value in Dictionary<string, GraduateStudet>: {ts6d}"); }
public TestCollections(int elem) { for (int i = 0; i < elem; i++) { GraduateStudet g = GenerateElement(i); PersonList.Add(g.PersonProperty); stringList.Add(g.PersonProperty.ToString()); typedKVDictionary.Add(g.PersonProperty, g); typedStringVDictionary.Add(g.PersonProperty.ToString(), g); } }
public void InsertAt(int j, GraduateStudet gs) { if (ListOfStudents[j] != null) { ListOfStudents.Insert(j - 1, gs); GraduateStudentInserted?.Invoke(this, new GraduateStudentListHandlerEventArgs("ListOfStudents", $"element was inserted to the {j - 1} posittion of the list", j - 1)); } else { ListOfStudents.Add(gs); GraduateStudentAdded?.Invoke(this, new GraduateStudentListHandlerEventArgs("ListOfStudents", "element was added to the end of the list", ListOfStudents.Count)); } }
public void AddDefaults() { /*c допомогою якого можна додати деяке число елементів * типу GraduateStudent для ініціалізації колекції за замовчуванням; */ int sizedef = 7; GraduateStudet[] p = new GraduateStudet[sizedef]; for (int i = 0; i < sizedef; i++) { GraduateStudet grd = new GraduateStudet(); grd.LastName = grd.LastName + i; p[i] = grd; } ListOfStudents.AddRange(p); GraduateStudentAdded?.Invoke(this, new GraduateStudentListHandlerEventArgs("ListOfStudents", "element was added to the end of the list", ListOfStudents.Count)); }
public override object DeepCopy() { GraduateStudet g = (GraduateStudet)this.MemberwiseClone(); g.PersonProperty = (Person)this.PersonProperty.DeepCopy(); g.EmployeePosition = new string(EmployeePosition); //String.Copy(EmployeePosition); g.Supervisor = (Person)this.Supervisor.DeepCopy(); g.Speciality = new string(Speciality); //String.Copy(Speciality); g.ArticlesPublished = new List<Article>(); for (int i = 0; i < ArticlesPublished.Count; i++) { g.ArticlesPublished.Add((Article)this.ArticlesPublished[i].DeepCopy()); } g.NotesMade = new List<Notes>(); foreach (Notes n in this.NotesMade) { g.NotesMade.Add((Notes)n.DeepCopy()); } return g; }