private void sortBtn_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(resulttxtBox.Text)) { return; } try { var str = resulttxtBox.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); int[] values = new int[str.Length]; for (int i = 0; i < str.Length; i++) { values[i] = int.Parse(str[i]); } if (insSort.IsChecked.HasValue && insSort.IsChecked.Value) { SortSearch <int> .InsertionSort(values); } if (selSort.IsChecked.HasValue && selSort.IsChecked.Value) { SortSearch <int> .SelectionSort(values); } if (bubSort.IsChecked.HasValue && bubSort.IsChecked.Value) { SortSearch <int> .BubbleSort(values); } if (heapSort.IsChecked.HasValue && heapSort.IsChecked.Value) { SortSearch <int> .HeapSort(values); } if (mergeSort.IsChecked.HasValue && mergeSort.IsChecked.Value) { SortSearch <int> .MergeSort(values); } if (quickSort.IsChecked.HasValue && quickSort.IsChecked.Value) { SortSearch <int> .QuickSort(values); } if (countSort.IsChecked.HasValue && countSort.IsChecked.Value) { SortSearch <int> .CountingSort((uint[])(object)values); // yes, it is wrong way to go :-) } if (bucketSort.IsChecked.HasValue && bucketSort.IsChecked.Value) { MessageBox.Show("Not implemented yet"); } resulttxtBox.Text = values.ToSimbolSeperatedString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void searchbtn_Click(object sender, RoutedEventArgs e) { try { int searchValue = int.Parse(this.searchtxtBox.Text); var str = resulttxtBox.Text.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); int[] values = new int[str.Length]; for (int i = 0; i < str.Length; i++) { values[i] = int.Parse(str[i]); } int index = SortSearch <int> .LinearSearch(values, searchValue); searchResult.Text = index == -1 ? "not found" : index.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ResponseWrapperClass<QuestionClass> Search(string site, int? page, int? pagesize, DateTimeOffset? fromdate, DateTimeOffset? todate, Order? order, object min, object max, SortSearch? sort, string tagged, string nottagged, string intitle) { string uriTemplate = _client.AppendApiKey("?site={site}&page={page}&pagesize={pagesize}&fromdate={fromdate}&todate={todate}&order={order}&min={min}&max={max}&sort={sort}&tagged={tagged}¬tagged={nottagged}&intitle={intitle}"); return _client.Request<ResponseWrapperClass<QuestionClass>>("search", uriTemplate , "GET", new Dictionary<string, object> { {"site",site}, {"page",page}, {"pagesize",pagesize}, {"fromdate",fromdate}, {"todate",todate}, {"order",order}, {"min",min}, {"max",max}, {"sort",sort}, {"tagged",tagged}, {"nottagged",nottagged}, {"intitle",intitle}, } , TimeSpan.FromMilliseconds(360000), "default",ContentType.JSON); }