private int GetBiggerLength(IOneDStringArray array) { if (Length >= array.Length) { return(Length); } return(array.Length); }
private void FillArr(IOneDStringArray obj) { Random random = new Random(); for (var i = 0; i < obj.Length; i++) { obj[i] = RandomString(5, random); } }
private void GetValue(IOneDStringArray obj) { var index = 0; Console.Write("Enter string number - "); if (int.TryParse(Console.ReadLine(), out index)) { Console.WriteLine($"Line Number {index} - {obj[index]}"); } Console.WriteLine(); }
public IOneDStringArray Merge(IOneDStringArray array) { var list = new HashSet <string>(); for (var i = 0; i < Length; i++) { list.Add(this[i]); } for (var i = 0; i < array.Length; i++) { if (!list.Contains(array[i])) { list.Add(array[i]); } } return(GetMergerResult(new OneDStringArray(list.Count), list)); }
public IOneDStringArray Concat(IOneDStringArray array) { int length = GetBiggerLength(array); var result = new OneDStringArray(length); for (var i = 0; i < result.Length; i++) { if (i < Length && i < array.Length) { result[i] = this[i] + array[i]; } else if (i < Length && i >= array.Length) { result[i] = this[i]; } else { result[i] = array[i]; } } return(result); }
private void DoConcatenate(IOneDStringArray obj) { Console.WriteLine("Concatenate an array with itself"); obj.Concat(obj).Print(); Console.WriteLine(); }
private void DoMerge(IOneDStringArray obj) { Console.WriteLine("Merge an array with itself. If successful, \r\nthe resulting array will match the original"); obj.Merge(obj).Print(); Console.WriteLine(); }