//Remove method: Removes the first instance of a value in an array public void Remove(T input) { SetList <T> temporaryList = new SetList <T>(); for (int i = 0; i < Counter; i++) { if (itemSeries[i].Equals(input)) { for (int j = 0; j < i; j++) { temporaryList.Add(itemSeries[j]); } int skipValue = (i + 1); for (int k = skipValue; k < Counter; k++) { temporaryList.Add(itemSeries[k]); } itemSeries = temporaryList.itemSeries; counter = temporaryList.Counter; break; } else { continue; } } }
//Overload "-" operator: Remove all instances of inputTwo values from inputOne public static SetList <T> operator -(SetList <T> inputOne, SetList <T> inputTwo) { for (int i = 0; i < inputTwo.Counter; i++) { for (int j = 0; j < inputOne.Counter; j++) { SetList <T> temporaryList = new SetList <T>(); if (inputTwo.itemSeries[i].Equals(inputOne.itemSeries[j])) { for (int k = 0; k < j; k++) { temporaryList.Add(inputOne.itemSeries[k]); } int skipValue = (j + 1); for (int l = skipValue; l < inputOne.Counter; l++) { temporaryList.Add(inputOne.itemSeries[l]); } inputOne.itemSeries = temporaryList.itemSeries; inputOne.counter = temporaryList.Counter; } else { continue; } } } return(inputOne); }
//Overload "+" operator: concat two arrays together public static SetList <T> operator +(SetList <T> inputOne, SetList <T> inputTwo) { SetList <T> temporaryList = new SetList <T>(); for (int i = 0; i < inputOne.Counter; i++) { temporaryList.Add(inputOne.itemSeries[i]); } for (int j = 0; j < inputTwo.Counter; j++) { temporaryList.Add(inputTwo.itemSeries[j]); } return(temporaryList); }
//This method was implemented to go with the SORT method. public SetList <string> ConvertToString() { SetList <string> temporaryList = new SetList <string>(); for (int i = 0; i < Counter; i++) { temporaryList.Add($"{itemSeries[i]}"); } return(temporaryList); }
//Zip method: Zips values from 2 arrays. If one array run out of values before the other, the remaining values of the longer // array gets thrown at the end. public SetList <T> Zip(SetList <T> inputTwo) { int temporaryCounter = 0; if (Counter >= inputTwo.Counter) { temporaryCounter = Counter; } else if (Counter < inputTwo.Counter) { temporaryCounter = inputTwo.Counter; } SetList <T> resultList = new SetList <T>(); int OneArrayOnlyCounter = 0; for (int i = 0; i < temporaryCounter; i++) { if (i < Counter && i < inputTwo.Counter) { resultList.Add(itemSeries[i]); resultList.Add(inputTwo.itemSeries[i]); } else { OneArrayOnlyCounter++; } if (OneArrayOnlyCounter > 0 && Counter > inputTwo.Counter) { resultList.Add(itemSeries[i]); } else if (OneArrayOnlyCounter > 0 && Counter < inputTwo.Counter) { resultList.Add(inputTwo.itemSeries[i]); } } return(resultList); }