Example #1
0
        public static CustomLists <T> operator -(CustomLists <T> list1, CustomLists <T> list2)
        {
            CustomLists <T> newList = list1;

            for (int i = 0; i < list2.Count; i++)
            {
                newList.Remove(list2.ElementAt(i));
            }
            return(newList);
        }
Example #2
0
        public CustomLists <T> ZipLists(CustomLists <T> list)
        {
            CustomLists <T> newList = new CustomLists <T>();

            for (int i = 0; i < count; i++)
            {
                newList.Add(array[i]);
                newList.Add(list[i]);
            }
            return(newList);
        }
Example #3
0
 public CustomLists <T> OverloadMinusOperator(CustomLists <T> listA, CustomLists <T> listB) // Overload Minus Operator needs two seperate list of the same data type to be passed in the parameter.
 {
     for (int i = 0; i < listA.Count; i++)                                                  // for loop sets conditons and loops through the size of of first list being passed
     {
         for (int j = 0; j < listB.Count; j++)                                              // secondary for loop sets conditons and loops through second list being passed
         {
             if (listA.array[i].Equals(listB.array[j]))                                     // if statement creates boolean condition for removal
             {
                 listA.Remove(listB.array[j]);                                              // All true matches are are removed and stored on the stack and repeated until loops finishes
             }
         }
     }
     return(listA);                                                                      // stack unwinds and a returns remaining list of non matching values
 }
Example #4
0
        public CustomLists <T> OverloadPlusOperator(CustomLists <T> listA, CustomLists <T> listB) // Overload Plus Operator needs two seperate list of the same data type to be passed in the parameter.
        {
            CustomLists <T> newCombinedLists = new CustomLists <T>();                             // list of the same data type is instantiated and declared

            newCombinedLists.array = new T[listA.Count + listB.Count];                            // new instantiated list is set to the size of the two list being passed

            for (int i = 0; i > listA.Count; i++)                                                 // new combined list loops and adds all List A items
            {
                newCombinedLists[i] = listA[i];
            }

            for (int i = 0; i > listB.Count; i++)                                               // new combined list loops and adds all List B items
            {
                newCombinedLists[i] = listA[i];
            }

            return(newCombinedLists);                                                            // new combined list is returned with combined Lists A&B
        }
Example #5
0
        public CustomLists <T> ZipLists(CustomLists <T> listA, CustomLists <T> listB)
        {
            CustomLists <T> zipLists = new CustomLists <T>();

            zipLists.array = new T[listA.Count + listB.Count];

            int j = 0;

            for (int i = 0; i < listA.Count; i++)
            {
                zipLists.array[j] = listA.array[i];
                j++;

                zipLists.array[j] = listB.array[i];
                j++;
            }
            return(zipLists);
        }