Beispiel #1
0
        static void Main(string[] args)
        {
            CustomListClass <int> customList;

            customList = new CustomListClass <int>();
            CustomListClass <int> otherList;

            otherList = new CustomListClass <int>();
            //CustomListClass<int> thirdList;
            //otherList = new CustomListClass<int>();

            customList.Add(4);
            customList.Add(0);
            customList.Add(6);
            customList.Add(7);
            customList.Add(-10);
            customList.Remove(6);
            otherList.Add(-10);
            otherList.Add(0);
            otherList.Add(4);

            Console.WriteLine(customList.ToString());
            Console.WriteLine(otherList.ToString());
            foreach (int item in customList)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine(customList + otherList);
            Console.WriteLine(customList - otherList);
            Console.ReadLine();
        }
        public CustomListClass <T> Zipper(CustomListClass <T> list1, CustomListClass <T> list2)
        {
            CustomListClass <T> tempList = new CustomListClass <T>();

            for (int i = 0; i < list2.Count; i++)
            {
                tempList.Add(list1[i]);
                tempList.Add(list2[i]);
            }
            return(tempList);
        }
        public static CustomListClass <T> operator -(CustomListClass <T> list1, CustomListClass <T> list2)
        {
            CustomListClass <T> array = new CustomListClass <T>();

            array = list1;
            foreach (T item in list2)
            {
                array.Remove(item);
            }

            return(array);
        }
        public static CustomListClass <T> operator+(CustomListClass <T> list1, CustomListClass <T> list2)
        {
            CustomListClass <T> array = new CustomListClass <T> ();

            foreach (T item in list1)
            {
                array.Add(item);
            }
            foreach (T item in list2)
            {
                array.Add(item);
            }
            return(array);
        }
Beispiel #5
0
        public static CustomListClass <T> operator +(CustomListClass <T> listOne, CustomListClass <T> listTwo)
        {
            CustomListClass <T> newList = new CustomListClass <T>();

            foreach (T item in listOne)
            {
                newList.Add(item);
            }
            foreach (T item in listTwo)
            {
                newList.Add(item);
            }
            return(newList);
        }
Beispiel #6
0
        // Overload +
        public static CustomListClass <T> operator +(CustomListClass <T> one, CustomListClass <T> two)
        {
            CustomListClass <T> three = new CustomListClass <T>();

            for (int i = 0; i < one.Count; i++)
            {
                three.Add(one.customArray[i]);
            }
            for (int i = 0; i < two.Count; i++)
            {
                three.Add(two.customArray[i]);
            }
            return(three);
        }
Beispiel #7
0
        public static CustomListClass <T> Zip(CustomListClass <T> firstList, CustomListClass <T> secondList)
        {
            CustomListClass <T> newList = new CustomListClass <T>();

            for (int i = 0; i < firstList.count || i < secondList.count; i++)
            {
                if (i < firstList.count)
                {
                    newList.Add(firstList[i]);
                }
                if (i < secondList.count)
                {
                    newList.Add(secondList[i]);
                }
            }
            return(newList);
        }
Beispiel #8
0
        public static CustomListClass <T> operator -(CustomListClass <T> listOne, CustomListClass <T> listTwo)
        {
            CustomListClass <T> newList = new CustomListClass <T>();
            int  k         = 0;
            bool itemFound = false;

            for (int i = 0; i < listOne.count; i++)
            {
                for (int j = 0; j < listTwo.count; j++)
                {
                    if (!itemFound)
                    {
                        if (listOne[i].Equals(listTwo[j]))
                        {
                            itemFound  = true;
                            newList[k] = listOne[i];
                            k++;
                        }
                    }
                }
            }
            return(newList);
        }