Exemple #1
0
 static void Main(string[] args)
 {
     customList <int> list = new customList <int> ()
     {
         3, 4
     };
 }
Exemple #2
0
        public static customList <T> operator +(customList <T> firstList, customList <T> secondList)
        {
            T[]            tempArray = new T[firstList.Capacity + secondList.Capacity];
            customList <T> addedList = new customList <T>();

            addedList.myArray = tempArray;

            for (int i = 0; i < firstList.Count; i++)
            {
                addedList.Add(firstList[i]);
            }
            for (int i = addedList.Count; i < firstList.Count + secondList.Count; i++)
            {
                addedList.Add(secondList[i - firstList.Count]);
            }
            return(addedList);
        }
Exemple #3
0
        public customList <T> Zip(customList <T> secondList)
        {
            T[]            tempArray  = new T[this.Capacity + secondList.Capacity];
            customList <T> zippedList = new customList <T>();

            zippedList.myArray = tempArray;

            if (this.Count > secondList.Count)
            {
                for (int i = 0; i < secondList.Count; i++)
                {
                    zippedList.Add(this[i]);
                    zippedList.Add(secondList[i]);
                }
                for (int i = secondList.Count; i < this.Count; i++)
                {
                    zippedList.Add(this[i]);
                }
            }
            else if (this.Count < secondList.Count)
            {
                for (int i = 0; i < this.Count; i++)
                {
                    zippedList.Add(this[i]);
                    zippedList.Add(secondList[i]);
                }
                for (int i = this.Count; i < secondList.Count; i++)
                {
                    zippedList.Add(secondList[i]);
                }
            }
            else
            {
                for (int i = 0; i < this.Count; i++)
                {
                    zippedList.Add(this[i]);
                    zippedList.Add(secondList[i]);
                }
            }

            return(zippedList);
        }
Exemple #4
0
        public static customList <T> operator -(customList <T> firstList, customList <T> secondList)
        {
            T[]            tempArray      = new T[firstList.Capacity];
            customList <T> subtractedList = new customList <T>();

            subtractedList.myArray = tempArray;

            for (int i = 0; i < firstList.Count; i++)
            {
                subtractedList.Add(firstList[i]);
            }
            for (int i = 0; i < secondList.Count; i++)
            {
                if (subtractedList[i].Equals(secondList[i]))
                {
                    subtractedList.Remove(secondList[i]);
                }
            }
            return(subtractedList);
        }