Exemple #1
0
        static void Main(string[] args)
        {
            MyCustomList <int> custom = new MyCustomList <int>();

            custom.Add(5);
            custom.Add(10);
            custom.Add(15);
            custom.Add(20);
            custom.Add(25);
            custom.Add(30);
            custom.Add(35);
            custom.Add(40);
            custom.Add(45);
            custom.Add(50);



            //List<int> userList = new List<int>();
            //userList.Add(5);
            //userList.Add(10);
            //userList.Add(15);
            //userList.Add(20);
            //userList.Add(25);

            //userList.Remove(5);
            //userList.Remove(20);
        }
Exemple #2
0
        public static void Main()
        {
            MyCustomList <string> elements = new MyCustomList <string>();

            string command = Console.ReadLine();

            while (command != "END")
            {
                string[] commandArgs = command.Split(' ');

                switch (commandArgs[0])
                {
                case "Add": elements.Add(commandArgs[1]); break;

                case "Remove": elements.Remove(int.Parse(commandArgs[1])); break;

                case "Contains": elements.Contains(commandArgs[1]); break;

                case "Swap": elements.Swap(int.Parse(commandArgs[1]), int.Parse(commandArgs[2])); break;

                case "Greater": elements.CountGreaterThan(commandArgs[1]); break;

                case "Max": elements.Max(); break;

                case "Min": elements.Min(); break;

                case "Print": elements.Print(); break;
                }
            }
        }
Exemple #3
0
        public static MyCustomList <T> operator -(MyCustomList <T> myList, MyCustomList <T> myListTwo)
        {
            MyCustomList <T> results = new MyCustomList <T>();

            results = myList;
            foreach (T item in myListTwo)
            {
                results.Remove(item);
            }
            return(results);
        }
Exemple #4
0
        private void ReplaceWithLargerArray(T item)
        {
            MyCustomList <T> replace = new MyCustomList <T>(count);

            for (int i = 0; i < count - 1; i++)
            {
                replace.myArr[i] = myArr[i];
            }
            replace.myArr[count - 1] = item;
            myArr    = replace.myArr;
            count    = replace.Count;
            capacity = replace.Capacity;
        }
Exemple #5
0
        public MyCustomList <T> Zip(MyCustomList <T> myList, MyCustomList <T> myListTwo)
        {
            MyCustomList <T> zipResults = new MyCustomList <T>();

            if (Count == myListTwo.Count)
            {
                for (int i = 0; i < Count; i++)
                {
                    zipResults.Add(myList[i]);
                    zipResults.Add(myListTwo[i]);
                }
            }
            return(zipResults);
        }
Exemple #6
0
        public static MyCustomList <T> operator +(MyCustomList <T> myList, MyCustomList <T> myListTwo)
        {
            MyCustomList <T> results = new MyCustomList <T>();

            for (int i = 0; i < myList.Count; i++)
            {
                results.Add(myList[i]);
            }
            for (int i = 0; i < myListTwo.Count; i++)
            {
                results.Add(myListTwo[i]);
            }
            return(results);
        }
Exemple #7
0
        public static MyCustomList <T> operator-(MyCustomList <T> load1, MyCustomList <T> load2)
        {
            //MyCustomList<int> unload1 = new MyCustomList<int>() { 5, 15, 25, 35, 45 };
            //MyCustomList<int> unload2 = new MyCustomList<int>() { 10, 20, 30, 40, 50 };
            //MyCustomList<int> result = unload1 - unload2;
            MyCustomList <T> result = new MyCustomList <T>();

            for (int i = 0; i < load1.count; i++)
            {
                result.Remove(load1[i]);
            }

            return(result);
        }
Exemple #8
0
        public static MyCustomList <T> operator +(MyCustomList <T> list1, MyCustomList <T> list2)
        {
            MyCustomList <T> replace = new MyCustomList <T>(list1.Count + list2.Count);

            for (int i = 0; i < list1.Count; i++)
            {
                replace.myArr[i] = list1.myArr[i];
            }
            for (int j = 0; j < list2.Count; j++)
            {
                replace.myArr[list1.Count + j] = list2.myArr[j];
            }
            return(replace);
        }
Exemple #9
0
        public static MyCustomList <T> operator +(MyCustomList <T> one, MyCustomList <T> two)
        {
            MyCustomList <T> combinedList = new MyCustomList <T>();

            for (int i = 0; i <= one.Count - 1; i++)
            {
                combinedList.Add(one[i]);
            }
            for (int i = 0; i <= two.Count - 1; i++)
            {
                combinedList.Add(two[i]);
            }

            return(combinedList);
        }
Exemple #10
0
        public MyCustomList <T> Zip(MyCustomList <T> load1, MyCustomList <T> load2)
        {
            MyCustomList <T> result = new MyCustomList <T>();

            for (int i = 0; i < load1.count; i++)
            {
                result.Add(load1[i]);
                result.Add(load2[i]);
            }


            // {
            // result.Add(load1[i]);
            // result.Add(load2[i]);
            // }

            return(result);
        }
Exemple #11
0
        public static MyCustomList <T> operator+(MyCustomList <T> load1, MyCustomList <T> load2)
        {
            //MyCustomList<int> load1 = new MyCustomList<int>() { 5, 15, 25, 35, 45 };
            //MyCustomList<int> load2 = new MyCustomList<int>() { 10, 20, 30, 40, 50 };
            //MyCustomList<int> result = load1 + load2;
            MyCustomList <T> result = new MyCustomList <T>();

            for (int i = 0; i < load1.count; i++)
            {
                result.Add(load1[i]);
            }
            for (int i = 0; i < load2.count; i++)
            {
                result.Add(load2[i]);
            }


            return(result);
        }
Exemple #12
0
        static void Main(string[] args)
        {
            MyCustomList <int> list1 = new MyCustomList <int>();

            list1.Add(12);
            list1.Add(22);
            list1.Add(32);
            MyCustomList <int> list2 = new MyCustomList <int>();

            list2.Add(42);
            list2.Add(62);
            list2.Add(72);


            MyCustomList <int> listoneplustwo = new MyCustomList <int>();

            listoneplustwo = list1 + list2;

            foreach (int number in listoneplustwo)
            {
                Console.WriteLine(number);
            }
            Console.ReadLine();
        }
Exemple #13
0
        public MyCustomList <T> ZipLists(MyCustomList <T> list1, MyCustomList <T> list2)
        {
            int i = 0;
            int j = 0;
            int k = 0;
            MyCustomList <T> replace = new MyCustomList <T>(list1.Count + list2.Count);

            while (i < list1.Count + list2.Count)
            {
                if (j < list1.Count)
                {
                    replace.myArr[i] = list1.myArr[j];
                    i++;
                    j++;
                }
                if (k < list2.Count)
                {
                    replace.myArr[i] = list2.myArr[k];
                    i++;
                    k++;
                }
            }
            return(replace);
        }