Ejemplo n.º 1
0
        public CList <T> Zip(CList <T> secondList)
        {
            int       combinedListCount = count + secondList.count;
            int       j          = 0;
            CList <T> ZippedList = new CList <T>();

            for (int i = 0; i < combinedListCount; i++)
            {
                if (j < count && j < secondList.count)
                {
                    ZippedList.Add(this[j]);
                    i++;
                    ZippedList.Add(secondList[j]);
                }
                else if (j < this.count && j >= secondList.count)
                {
                    ZippedList.Add(this[j]);
                }
                else if (j >= count && j < secondList.count)
                {
                    ZippedList.Add(secondList[j]);
                }
                j++;
            }
            count = combinedListCount;
            return(ZippedList);
        }
Ejemplo n.º 2
0
        public static CList <T> operator-(CList <T> first, CList <T> second)
        {
            CList <T> subtractedList = new CList <T>();

            for (int i = 0; i < second.count; i++)
            {
                for (int j = 0; j < first.count; j++)
                {
                    if (first[j].Equals(second[i]))
                    {
                        first[j] = second[second.count - 1];
                    }
                }
            }
            for (int i = 0; i < first.count; i++)
            {
                if (first[i].Equals(second[second.count - 1]))
                {
                    //do nothing
                }
                else
                {
                    subtractedList.Add(first[i]);
                }
            }
            return(subtractedList);
        }
Ejemplo n.º 3
0
        public static CList <T> operator +(CList <T> firstList, CList <T> secondList)
        {
            CList <T> CombinedList = new CList <T>();

            CombinedList.Join(firstList, secondList);
            CombinedList.count = firstList.count + secondList.count;
            return(CombinedList);
        }
Ejemplo n.º 4
0
        public void Join(CList <T> firstList, CList <T> secondList)
        {
            int combinedListCapacity = (firstList.capacity + secondList.capacity);

            T[] CombinedList = new T[combinedListCapacity];
            for (int i = 0; i < firstList.count; i++)
            {
                CombinedList[i] = firstList[i];
                CombinedList[i + firstList.count] = secondList[i];
            }
            cArray = CombinedList;
        }
Ejemplo n.º 5
0
        public CList <T> Zip(CList <T> secondList)
        {
            CList <T> firstList    = this;
            CList <T> combinedList = new CList <T>();

            for (int i = 0; i < secondList.count; i++)
            {
                combinedList.Add(firstList[i]);
                combinedList.Add(secondList[i]);
            }

            return(combinedList);
        }
Ejemplo n.º 6
0
        public static CList <T> operator +(CList <T> x, CList <T> y)
        {
            CList <T> Fraction = new CList <T>();

            for (int i = 0; i <= x.Count - 1; i++)
            {
                Fraction.Add(x[i]);
            }
            for (int i = 0; i <= y.Count - 1; i++)
            {
                Fraction.Add(y[i]);
            }
            return(Fraction);
        }
Ejemplo n.º 7
0
        public static CList <T> operator -(CList <T> firstList, CList <T> secondList)
        {
            CList <T> ReducedList = new CList <T>();

            foreach (T input in firstList)
            {
                ReducedList.Add(input);
            }
            foreach (T input in secondList)
            {
                ReducedList.Remove(input);
            }
            return(ReducedList);
        }
Ejemplo n.º 8
0
        public static CList <T> operator -(CList <T> x, CList <T> y)
        {
            CList <T> Fraction = new CList <T>();

            for (int i = 0; i <= x.Count - 1; i++)
            {
                for (int j = 0; j <= y.Count - 1; j++)
                {
                    if (!x[i].Equals(y[j]))
                    {
                        Fraction.Add(x[i]);
                    }
                }
            }
            return(Fraction);
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            CList <int> List1 = new CList <int>()
            {
                10, 20, 30
            };
            CList <int> List2 = new CList <int>()
            {
                30, 20, 60
            };
            CList <int> expected = new CList <int>()
            {
                10
            };

            CList <int> actual;

            actual = List1 - List2;
            int Count          = 2;
            int expectedResult = Count;

            // act
        }