Example #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);
        }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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);
        }
Example #5
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;
                }
            }
        }
Example #6
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);
        }
Example #7
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);
        }
        public void InterpredCommand(string input)
        {
            var tokens  = input.Split(' ');
            var command = tokens[0];

            switch (command)
            {
            case "Add":
                var element = tokens[1];
                myList.Add(element);
                break;

            case "Remove":
                var index = int.Parse(tokens[1]);
                myList.Remove(index);
                break;

            case "Contains":
                element = tokens[1];
                Console.WriteLine(myList.Contains(element));
                break;

            case "Swap":
                var firstIndex  = int.Parse(tokens[1]);
                var secondIndex = int.Parse(tokens[2]);
                myList.Swap(firstIndex, secondIndex);
                break;

            case "Greater":
                element = tokens[1];
                Console.WriteLine(myList.CountGreaterElements(element));
                break;

            case "Max":
                Console.WriteLine(myList.Max());
                break;

            case "Min":
                Console.WriteLine(myList.Min());
                break;

            case "Print":
                Console.WriteLine(myList.Print());
                break;

            case "Sort":
                myList.Sort();
                break;
            }
        }
Example #9
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();
        }