Exemplo n.º 1
0
        public async void Sort()
        {
            string[] arr = await Task.Run(() =>
            {
                InputText      = InputText.Trim();
                string[] array = Split(InputText);
                if (array.Length > 0)
                {
                    GC.Collect();
                    BubbleSortingTime = (int)ActionTimeMeasurer.Measure(new Action(() =>
                                                                                   BubbleSorter.Sort(array)));
                    array = Split(InputText);
                    if (array.Length > 0)
                    {
                        GC.Collect();
                        MergeSortingTime = (int)ActionTimeMeasurer.Measure(new Action(() =>
                                                                                      MergeSorter.Sort(array)));
                    }
                    WordsInText = array.Length;
                }
                return(array);
            });

            ArrToObsColl(arr);
            CalcWords(arr);
            SortTextLabel     = "Sort Text";
            UniqueWordsInText = SortedTextWords.Count();
            RaisePropertyChanged("SortTextLabel");
            UpdateInfo();
        }
Exemplo n.º 2
0
 public void ClearInfo()
 {
     SortedTextWords.Clear();
     SortedText.Clear();
     WordsInText       = 0;
     UniqueWordsInText = 0;
     MergeSortingTime  = 0;
     BubbleSortingTime = 0;
     UpdateInfo();
 }
Exemplo n.º 3
0
 public void CalcWords(string[] arr)
 {
     for (int i = 0; i < arr.Length; i++)
     {
         string str   = arr[i];
         int    count = 0;
         while (i < arr.Length && arr[i] == str)
         {
             if (i < arr.Length)
             {
                 count++;
             }
             i++;
         }
         i--;
         SortedTextWords.Add(new El(str, count));
     }
 }