Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 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());
 }
Ejemplo n.º 4
0
 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]);
 }
Ejemplo n.º 5
0
 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]);
 }
Ejemplo n.º 6
0
 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());
 }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
 public void Initialize()
 {
     list = new MyList<int>();
 }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 public void Initialize()
 {
     list = new MyList <int>();
 }
Ejemplo n.º 11
0
 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]);
 }
Ejemplo n.º 12
0
 public void AddTest(MyList.iMList list)
 {
     list.Add(5);
     int expected = 5;
     NUnit.Framework.Assert.AreEqual(expected, list[0]);
 }
Ejemplo n.º 13
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]);
 }