private void FillAlgorithms() { AlgorithmComboBox.Items.Add(new SorterComboItem <double> ( "Bubble Sort", SorterFactory.CreateSorter <BubbleSorter <double>, double>() )); AlgorithmComboBox.Items.Add(new SorterComboItem <double> ( "Selection Sort", SorterFactory.CreateSorter <SelectionSorter <double>, double>() )); AlgorithmComboBox.Items.Add(new SorterComboItem <double> ( "Insertion Sort", SorterFactory.CreateSorter <InsertionSorter <double>, double>() )); AlgorithmComboBox.Items.Add(new SorterComboItem <double> ( "Shell Sort", SorterFactory.CreateSorter <ShellSorter <double>, double>() )); AlgorithmComboBox.Items.Add(new SorterComboItem <double> ( "Merge Sort", SorterFactory.CreateSorter <MergerSorter <double>, double>() )); AlgorithmComboBox.Items.Add(new SorterComboItem <double> ( "Quick Sort", SorterFactory.CreateSorter <QuickSorter <double>, double>() )); AlgorithmComboBox.SelectedIndex = 0; }
private int TestSortings(SortingAlgorithm algorithm, int[] array) { var sorter = SorterFactory.GetSorter(); var swapped = sorter.Sort(algorithm, array); return(swapped); }
public static void TestFixtureSetup(TestContext context) { var sorterFactory = new SorterFactory(); _lineSorter = sorterFactory.GetSorter(SortOptions.Line); _characterSorter = sorterFactory.GetSorter(SortOptions.Character); _wordSorter = sorterFactory.GetSorter(SortOptions.Word); }
public CustomComparatorSource(string sorterName, string databaseName, IndexQueryServerSide query) { _query = query; _factory = SorterCompilationCache.Instance.GetItemType(sorterName, databaseName); if (_factory == null) { SorterDoesNotExistException.ThrowFor(sorterName); } }
public string GetExchangeResults() { var result = new StringBuilder(); var sorter = SorterFactory.GetSorter(); var items = GetItemResults(); var sortedItems = sorter.OrderList(items); foreach (var item in sortedItems) { result.Append($"{item.Currency} {item.Rate:N4}\n"); } return(result.ToString()); }
public HttpResponseMessage GetMovies([FromUri] PagingParameterModel pagingParameterModel, [FromUri] SearchParameterModel searchParameterModel) { //System.Diagnostics.Debug.WriteLine("Session " + System.Web.HttpContext.Current.Session!=null); //foreach (string key in HttpContext.Current.Session.Contents) //{ // string value = "Key: " + key + ", Value: " + HttpContext.Current.Session[key].ToString(); // System.Diagnostics.Debug.WriteLine(value); //} if (pagingParameterModel == null) { pagingParameterModel = new PagingParameterModel(); } if (searchParameterModel == null) { searchParameterModel = new SearchParameterModel(); } // list of all movies var source = _movieRepository.GetMovies(searchParameterModel.SearchString); var filtered = Filter(source, searchParameterModel.Year, searchParameterModel.Genre); var sorted = new SorterFactory().Get(searchParameterModel.Order).Sorted(filtered).AsQueryable(); // number of movies in db int count = source.Count(); int CurrentPage = pagingParameterModel.PageNumber; int PageSize = pagingParameterModel.PageSize; int TotalCount = count; int TotalPages = (int)Math.Ceiling(count / (double)PageSize); var items = sorted .Skip((CurrentPage - 1) * PageSize) .Take(PageSize) .ToList(); var movies = ToMovieListViewModel(items); var previousPage = CurrentPage > 1 ? "Yes" : "No"; var nextPage = CurrentPage < TotalPages ? "Yes" : "No"; var paginationMetadata = new { totalCount = TotalCount, pageSize = PageSize, currentPage = CurrentPage, totalPages = TotalPages, previousPage, nextPage }; // Setting Header HttpContext.Current.Response.Headers.Add("Paging-Headers", JsonConvert.SerializeObject(paginationMetadata)); return(Request.CreateResponse(HttpStatusCode.OK, movies)); }
public SuperFactory(ArrayFactory af, SorterFactory sf) { this.af = af; this.sf = sf; }
public TextService() { _sorterFactory = new SorterFactory(); }
public SorterContext(int sorterType) { SorterAlgorithm = SorterFactory.GetSorter(sorterType); }