static void Main(string[] args) { MyList.MyList list = new MyList.MyList(); Console.WriteLine("Ввдите кол-во добовляемых значений: "); int count = int.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { list.MyAdd(int.Parse(Console.ReadLine())); } list.MyOutput(); Console.WriteLine($"Максимальное значение: {list.MyMax()}"); int[] mas = list.GetElements((x) => x % 2 == 0); for (int i = 0; i < mas.Length; i++) { Console.Write(mas[i] + " "); } Console.WriteLine(); Console.ReadLine(); }
public void RemoveTest(MyList.iMList list) { list.Add(5); list.Add(3); int expected = 1; list.Remove(5); NUnit.Framework.Assert.AreEqual(expected, list.Count()); }
public void CountTest(MyList.iMList list) { list.Add(5); list.Add(5); list.Add(5); int expected = 3; NUnit.Framework.Assert.AreEqual(expected, list.Count()); }
public void InsertTest(MyList.iMList lst) { lst.Add(1); lst.Add(2); lst.Add(3); lst.Add(4); lst.Add(5); lst.Insert(2, 10); int expected = 10; NUnit.Framework.Assert.AreEqual(expected, lst[2]); }
public void DeleteTest(MyList.iMList lst) { lst.Add(1); lst.Add(2); lst.Add(3); lst.Add(4); lst.Add(5); lst.Delete(2); int expected = 4; NUnit.Framework.Assert.AreEqual(expected, lst[2]); }
public void ClearTest(MyList.iMList list) { list.Add(5); list.Add(4); list.Add(3); list.Add(2); list.Add(1); int expected = 0; list.Clear(); NUnit.Framework.Assert.AreEqual(expected, list.Count()); }
static void Main(string[] args) { Obj one = new Obj(); one.set(10); MyList List = new MyList(); List.Add(one); Obj two = new Obj(); two.set(20); List.Add(two); List.Clear(); Obj three = new Obj(); three.set(30); List.Add(three); Obj fourth = new Obj(); fourth.set(89); List.Insert(1, fourth); Obj five = new Obj(); five.set(289); List.Insert(1, five); //List.Remove(one); //List.Remove(five); //List.Remove(three); //List.Remove(two); //List.Add(three); //List.RemoveAt(2); List.ShowArray(); Console.ReadLine(); }
public void Initialize() { list = new MyList<int>(); }
static void Main(string[] args) { var myList1 = new MyList <int>(); OutputMyList(myList1); var myList2 = new MyList <int>(10); OutputMyList(myList2); var myList3 = new MyList <int>(10, 9); OutputMyList(myList3); myList1.Add(10); OutputMyList(myList1); myList2.AddRange(new int[] { 20, 20, 20 }); OutputMyList(myList2); myList1.Clear(); OutputMyList(myList1); Console.WriteLine(myList3.Contains(9)); OutputMyList(myList3); var array = Tools.CreateUnsortedArray(20); Sorts.Sorts.MergeSort(array); myList1.AddRange(array); var aim = (new Random()).Next(20); Console.WriteLine($"Aim: {aim}"); OutputMyList(myList1); Console.WriteLine(myList1.BinarySearch(aim)); OutputMyList(myList1.ConvertAll(value => (char)value)); array = new int[20]; myList1.CopyTo(array); myList1.AddRange(array); OutputMyList(myList1); Console.WriteLine("Exists: " + myList1.Exists(x => x == 10)); Console.WriteLine("Find: " + myList1.Find(x => x == 10)); Console.WriteLine("FindLast: " + myList1.FindLast(x => x == 10)); Console.WriteLine("FindAll.Count: " + myList1.FindAll(x => x == 10)?.Count); Console.WriteLine("FindIndex: " + myList1.FindIndex(x => x == 10)); Console.WriteLine("FindLastIndex: " + myList1.FindLastIndex(x => x == 10)); Console.WriteLine("IndexOf: " + myList1.IndexOf(10)); Console.WriteLine("LastIndexOf: " + myList1.LastIndexOf(10)); OutputMyList(myList1.GetRange(3, 4)); myList1.Insert(2, -1); OutputMyList(myList1); myList1.Remove(-1); myList1.RemoveRange(37, 2); myList1.RemoveAt(0); myList1.RemoveAll(x => x == 8); OutputMyList(myList1); }
public void Initialize() { list = new MyList <int>(); }
public void AddToStartTest(MyList.iMList lst) { lst.Add(1); lst.Add(2); lst.Add(3); lst.AddToStart(10); int expected = 10; NUnit.Framework.Assert.AreEqual(expected, lst[0]); }
public void AddTest(MyList.iMList list) { list.Add(5); int expected = 5; NUnit.Framework.Assert.AreEqual(expected, list[0]); }
public void DelFirstTest(MyList.iMList lst) { lst.Add(1); lst.Add(2); lst.Add(3); lst.DelFirst(); int expected = 2; NUnit.Framework.Assert.AreEqual(expected, lst[0]); }