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(); }
public void ClearInfo() { SortedTextWords.Clear(); SortedText.Clear(); WordsInText = 0; UniqueWordsInText = 0; MergeSortingTime = 0; BubbleSortingTime = 0; UpdateInfo(); }
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)); } }