Esempio n. 1
0
 private int GetBiggerLength(IOneDStringArray array)
 {
     if (Length >= array.Length)
     {
         return(Length);
     }
     return(array.Length);
 }
Esempio n. 2
0
        private void FillArr(IOneDStringArray obj)
        {
            Random random = new Random();

            for (var i = 0; i < obj.Length; i++)
            {
                obj[i] = RandomString(5, random);
            }
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 private void DoConcatenate(IOneDStringArray obj)
 {
     Console.WriteLine("Concatenate an array with itself");
     obj.Concat(obj).Print();
     Console.WriteLine();
 }
Esempio n. 7
0
 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();
 }