Пример #1
0
        public void ListZipper(BriansList <T> listOne, BriansList <T> listTwo)
        {
            BriansList <T> zippedList = new BriansList <T>();

            for (int i = 0; i < listOne.count + listTwo.count; i++)
            {
                zippedList.Add(listOne[i]);
                zippedList.Add(listTwo[i]);
            }
            arr = zippedList.arr;
            //
        }
Пример #2
0
        public static BriansList <T> operator+(BriansList <T> listOne, BriansList <T> listTwo)
        {
            BriansList <T> newList = new BriansList <T>();

            for (int i = 0; i < listOne.count; i++)
            {
                newList.Add(listOne[i]);
            }
            for (int i = 0; i < listTwo.count; i++)
            {
                newList.Add(listTwo[i]);
            }
            return(newList);
        }
Пример #3
0
        static void Main(string[] args)
        {
            BriansList <int> listOne        = new BriansList <int>();
            BriansList <int> listTwo        = new BriansList <int>();
            BriansList <int> listToSubtract = listOne;

            listOne.Add(1);
            listOne.Add(2);
            listOne.Add(3);
            listTwo.Add(4);
            listTwo.Add(5);
            listTwo.Add(6);
            BriansList <int> newList = listOne + listTwo;

            //Act
            BriansList <int> reducedList = newList - listOne;
        }
Пример #4
0
        public static BriansList <T> operator-(BriansList <T> newList, BriansList <T> listToSubtract)
        {
            BriansList <T> reducedList = new BriansList <T>();

            for (int j = 0; j < newList.count; j++)
            {
                if (listToSubtract[0].Equals(newList[j]) && listToSubtract[1].Equals(newList[j + 1]) && listToSubtract[2].Equals(newList[j + 2]))
                {
                    newList.Remove(listToSubtract[j]);
                    newList.Remove(listToSubtract[j + 1]);
                    newList.Remove(listToSubtract[j + 2]);
                }
                else
                {
                    return(newList); // no list found to remove
                }
            }
            reducedList = newList;
            return(reducedList);
        }