static void Main(string[] args) { List <int> list = new List <int> { 1, 4, 5, 9 }; CustomBuiltList <int> one = new CustomBuiltList <int>() { 1, 3, 5 }; CustomBuiltList <int> two = new CustomBuiltList <int>() { 2, 4, 6 }; CustomBuiltList <int> three = new CustomBuiltList <int>() { 2, 1, 6 }; //CustomBuiltList<int> zipList = new CustomBuiltList<int>() { 1, 3, 5 }; //zipList.Zip(one, two); //T[] zipList1 = new T[]; //T[] zipList2 = new CustomList<int>() { 2, 4, 6 }; //zipList1.Zip(zipList1, zipList2); //CustomList<string> myRemoveList = new CustomList<string>() { "hello", "world", "code" }; //myRemoveList.Remove("world"); //CustomList<int> resultOne = new CustomList<int>(); CustomBuiltList <int> resultTwo = new CustomBuiltList <int>(); //resultOne = one + two; resultTwo = one - three; Console.WriteLine(resultTwo); Console.ReadLine(); //CustomList<int> customList = new CustomList<int>(); //customList.Add(2); //customList.Add(7); //customList.Add(10); //customList.Add(22); //customList.Add(4); //BuiltInListMethod builtIn = new BuiltInListMethod(); //builtIn.RunList(); //List<int> list = new List<int>(); //list.Add(2); //list.Add(4); //list.Add(6); //list.Add(24); //list.Add(13); }
public CustomBuiltList <string> ToStringList() { CustomBuiltList <string> customStringList = new CustomBuiltList <string>(); try { //1 //CustomList<string> customStringList = new CustomList<string>(); //foreach (string value in items) //{ // customStringList.Add(value); //} //2 //for (int i = 0; i < count; i++) //{ // if (items[i].Equals(item)) // { // foreach (string character in items[i]) // { // items[i] = character; // } // } //} //3 //use StringBuilder or concat for (int i = 0; i < count; i++) { foreach (T value in items) { string test = Convert.ToString(value); customStringList[i] = test; return(customStringList); } } return(customStringList); } catch { return(customStringList); } }
public CustomBuiltList <T> Zip(CustomBuiltList <T> items, CustomBuiltList <T> items1) { int j = 0; CustomBuiltList <T> tempList = new CustomBuiltList <T>(); for (int i = 0; i < count; i++) { tempList.Add(items[i]); tempList.Add(items1[j++]); } //foreach (T value in items) //{ // tempList.Add(value); // tempList.Remove(value1); // foreach (T value1 in items1) // { // tempList.Add(value1); // } //} //Console.WriteLine(tempList); //Console.ReadLine(); return(tempList); // int i = 0; // T[] temp = new T[capacity]; //for(i = 0; i < count; i++) // { // temp[i]=items[i]; // } //for(int j = 1; j < count; j++) // { // temp[i] // } }
//overload operator - public static CustomBuiltList <T> operator -(CustomBuiltList <T> comparableListA, CustomBuiltList <T> comparableListB) { CustomBuiltList <T> afterSubtraction = new CustomBuiltList <T>(); CustomBuiltList <T> listOutput = new CustomBuiltList <T>(); //GenerateCapacity(); for (int i = 0; i < comparableListA.count; i++) { comparableListA.Remove(comparableListB[i]); } return(comparableListA); //0 //for (int j = 0; j < comparableListA.count; j++) //{ // if (comparableListA[j].Equals(comparableListB[j])) // { // afterSubtraction.Add(comparableListA[j]); // } // else // { // //int nextIndex = i + 1; // //afterSubtraction.Add(comparableListA[j]); // //afterSubtraction.Add(comparableListB[i]); // } //} //0.5 //for (int i = 0; i < comparableListB.count; i++) //{ // if (comparableListA[i].Equals(comparableListB[i])) // { // afterSubtraction.Add(comparableListB[i]); // } // else // { // } //} //1 //CustomBuiltList<T> afterSubtraction = new CustomBuiltList<T>(); //int j = afterSubtraction.count; //int k = comparableListA.count; //int l = comparableListB.count; //foreach (T value in comparableListA) //{ // afterSubtraction.Add(value); //} //foreach (T value1 in comparableListB) //{ // afterSubtraction.Add(value1); //} //for (int i = 0; i < afterSubtraction.count; i++) //{ // foreach (T value in comparableListA) ; // foreach (T value1 in comparableListB) ; // if (!afterSubtraction[i].Equals(comparableListA[i])) // { // listOutput.Add(comparableListA[i]); // } // foreach (T value2 in afterSubtraction) // { // if (!afterSubtraction[i].Equals(comparableListB[i])) // { // listOutput.Add(comparableListB[i]); // } // } //} //2 //for (int i = 0; i < comparableListB.count; i++) //{ // for (int j = 0; i < comparableListA.count; j++) // if (!comparableListA[i].Equals(comparableListB[i])) // { // afterSubtraction.Add(comparableListB[i]); // afterSubtraction.Add(comparableListA[i]); // } // else // { // //int nextIndex = i + 1; // //c.Remove(comparableListB[nextIndex]); // } //} //return listOutput; }