Exemplo n.º 1
0
        public ListClass <T> MoveIntoOtherArray()
        {
            ListClass <T> tempList = new ListClass <T>();

            for (int i = 0; i < length; i++)
            {
                tempList.Add(innerArray[i]);
            }
            return(tempList);
        }
Exemplo n.º 2
0
        public ListClass <T> Zip(ListClass <T> list2)
        {
            ListClass <T> temporaryZip = new ListClass <T>();
            ListClass <T> largerList   = new ListClass <T>();

            int zipLength  = this.length;
            int difference = 0;

            largerList = this;

            if (this.length < list2.length)
            {
                zipLength  = this.length;
                difference = list2.length - this.length;
                largerList = list2;
            }
            else if (list2.length < this.length)
            {
                zipLength  = list2.length;
                difference = this.length - list2.length;
            }

            for (int i = 0; i < zipLength; i++)
            {
                temporaryZip.Add(this.innerArray[i]);
                temporaryZip.Add(list2.innerArray[i]);
            }

            if (this.length != list2.length)
            {
                for (int i = zipLength; i < zipLength + difference; i++)
                {
                    temporaryZip.Add(largerList.innerArray[i]);
                }
            }
            return(temporaryZip);
        }
Exemplo n.º 3
0
        public static ListClass <string> operator +(ListClass <T> list1, ListClass <T> list2)
        {
            string temporaryVariable;

            ListClass <string> addedList  = new ListClass <string>();
            ListClass <T>      largerList = new ListClass <T>();

            int zipLength  = list1.length;
            int difference = 0;

            if (list1.length < list2.length)
            {
                difference = list2.length - list1.length;
                largerList = list2;
            }
            else if (list2.length < list1.length)
            {
                zipLength  = list2.length;
                difference = list1.length - list2.length;
                largerList = list1;
            }
            for (int i = 0; i < zipLength; i++)
            {
                temporaryVariable = String.Format("{0} {1}", list1.innerArray[i], list2.innerArray[i]);
                addedList.Add(temporaryVariable);
            }

            if (list1.length != list2.length)
            {
                for (int i = zipLength; i < zipLength + difference; i++)
                {
                    addedList.Add(String.Format("{0}", largerList.innerArray[i]));
                }
            }
            return(addedList);
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            ListClass <string> words = new ListClass <string>();

            for (int i = 0; i < 10; i++)
            {
                words.Add("dog");
                words.Add("bike");
                words.Add("hippo");
                words.Add("table");
                words.Add("sunflower");
                words.Add("bottle");
            }

            foreach (string number in words)
            {
                Console.WriteLine(number);
            }
            words.Sort();
            foreach (string number in words)
            {
                Console.WriteLine(number);
            }

            Console.ReadLine();
            words.SortLengthAscending();
            foreach (string number in words)
            {
                Console.WriteLine(number);
            }
            Console.ReadLine();


            words.SortLengthDescending();
            foreach (string number in words)
            {
                Console.WriteLine(number);
            }
            Console.ReadLine();

            ListClass <int> numbers2 = new ListClass <int>();

            for (int i = 2; i < 20; i += 2)
            {
                numbers2.Add(i);
            }

            foreach (int number in numbers2)
            {
                Console.WriteLine(number);
            }
            Console.ReadLine();
            ListClass <int> numbers = new ListClass <int>();

            for (int i = 0; i < 11; i++)
            {
                numbers.Add(i);
            }


            foreach (int number in numbers)
            {
                Console.WriteLine(number);
            }

            //ListClass<string> newNumbers = new ListClass<string>();
            //newNumbers = numbers + numbers2;
            //foreach (string number in newNumbers)
            //{
            //    Console.WriteLine(number);
            //}
            //Console.ReadLine();

            //Console.WriteLine(numbers.ToString());
            //Console.WriteLine(numbers);
            //Console.ReadLine();

            ListClass <int> newList = new ListClass <int>();

            newList = numbers - numbers2;

            foreach (int item in newList)
            {
                Console.WriteLine(item);
            }

            //ListClass<int> numbersA = new ListClass<int>();
            //ListClass<int> numbersB = new ListClass<int>();
            //ListClass<int> zippedList = new ListClass<int>();

            //for (int i = 1; i < 16; i++)
            //{
            //    numbersA.Add(1);
            //}
            //for (int i = 1; i < 16; i++)
            //{
            //    numbersB.Add(2);
            //}

            //foreach (int item in numbersA)
            //{
            //    Console.WriteLine(item);
            //}
            //foreach (int item in numbersB)
            //{
            //    Console.WriteLine(item);
            //}
            Console.ReadLine();

            //zippedList = numbersA.Zip(numbersB);

            //foreach (int item in zippedList)
            //{
            //    Console.WriteLine(item);
            //}


            //Console.WriteLine(zippedList.CountList());

            //Console.ReadLine();
        }