public static SortingAlgorithmBase GetAlgorithm(ISortingHandable handleable, SortingTypes sortingType) { SortingAlgorithmBase result = null; switch (sortingType) { case SortingTypes.Bubble: result = SortingAlgorithmCreator.CreateBubbleSorting(handleable); break; case SortingTypes.Shaker: result = SortingAlgorithmCreator.CreateShakerSorting(handleable); break; case SortingTypes.Insertion: result = SortingAlgorithmCreator.CreateInsertionSorting(handleable); break; case SortingTypes.InsertionBinary: result = SortingAlgorithmCreator.CreateInsertionBinarySorting(handleable); break; //case SortingTypes.QuickSort: // result = SortingAlgorithmCreator.CreateQuickSort(handleable); // break; } return(result); }
private static UIAlertAction CreateAlertButton(String buttonName, SortingTypes sortingType, Action applyChanges = null) { return(UIAlertAction.Create(buttonName, UIAlertActionStyle.Default, delegate { NSUserDefaults.StandardUserDefaults.SetInt((int)sortingType, UserDefaultsKeys.SortingType); applyChanges?.Invoke(); })); }
/// <summary> /// Sort the collection of games by specified sort type. /// </summary> /// <param name="games"></param> /// <param name="sortType">The sort type.</param> /// <returns>The sorted collection of games.</returns> /// <exception cref="ArgumentOutOfRangeException">if sortType is not of SortingTypes.</exception> public static IEnumerable <Game> SortBy(this IEnumerable <Game> games, SortingTypes sortType) { IEnumerable <Game> result; switch (sortType) { case SortingTypes.Default: result = games; break; case SortingTypes.ReleaseDate: result = games.OrderByDescending(g => g.GameInfo.ReleaseDate); break; case SortingTypes.Alphabetically: result = games.OrderBy(g => g.Name); break; case SortingTypes.PriceDescending: result = games.OrderByDescending(g => (decimal)(1 - g.GameInfo.Discount) * g.GameInfo.Price); break; case SortingTypes.PriceAscending: result = games.OrderBy(g => (decimal)(1 - g.GameInfo.Discount) * g.GameInfo.Price); break; default: throw new ArgumentOutOfRangeException(nameof(sortType), sortType, null); } return(result); }
private void ResetSortType(RecursiveObservableCollection <ICraftingTreeItem> .ChildElementPropertyChangedEventArgs e) { if (_canResetSort) { SortType = "----------"; CB_SortingTypes.SelectedIndex = SortingTypes.IndexOf(SortType); } }
public void ResetSortType(RecursiveObservableCollection <IGatheringListItem> .ChildElementPropertyChangedEventArgs e) { if (_canResetSort) { SortType = "----------"; CB_SortingTypes.SelectedIndex = SortingTypes.IndexOf(SortType); } }
public MenuItem(string name, ConsoleColor color, ConsoleColor errorColor, int spacing, bool showCursor, ErrorProfile errorProfile, SortingTypes sortingType) { this.name = name; this.spacing = spacing; this.showCursor = showCursor; this.color = color; this.errorColor = errorColor; this.errorProfile = errorProfile; this.sortingType = sortingType; }
public void Sort(SortingTypes i_Type, SortingByTypes i_SortByType) { this._SortingType = i_Type; this._SortByType = i_SortByType; if (this._SortByType != SortingByTypes.None) //2009-3-11 10:16:57@Simon { this.InnerList.Sort(this); } }
public IActionResult SortAndFilter(string[] genresIds, string[] featuresIds, string[] pricesIds, string[] sortsIds, string searchStr) { searchStr = searchStr is null ? "" : searchStr; if (!string.IsNullOrEmpty(searchStr)) { ViewBag.isRedirectedFromOtherPageBySearchBtn = true; } IEnumerable <Game> foundGames = gamesTable.SearchGames(searchStr); // construct all filters by data received from page GameFilter?filter = new GameFilter { Genres = genresIds.Select(id => genresTable.GetGenreByUrlId(id)).ToList() !, Features = featuresIds.Select(id => featuresTable.GetFeatureByUrlId(id)).ToList() ! }; if (filter.Genres.Count == 0 && filter.Features.Count == 0) { filter = null; } // construct all categories by data received from page List <PriceCategory> categories = pricesIds.Select( id => priceCategoriesTable.GetCategoryByUrlId(id) ).ToList() !; // get sort type by data received from page SortingTypes sortType = HomeViewModel.SortingItems[sortsIds[0]].Value; // get filtered and sorted games IEnumerable <Game> filteredAndSortedGames = gamesTable .GetGamesByFilter(filter !, categories) .SortBy(sortType); IEnumerable <Game> result; // to avaoid multiple enumeration IEnumerable <Game> foundAsList = foundGames as Game[] ?? foundGames.ToArray(); IEnumerable <Game> filteredAndSortedAsList = filteredAndSortedGames as Game[] ?? filteredAndSortedGames.ToArray(); // find intersection between found games and filtered games result = filteredAndSortedAsList.Where( g => foundAsList.FirstOrDefault(fg => fg.Id == g.Id) != null ); IEnumerable <GameCard> gameCards = CreateGameCards(result); return(PartialView("_GamesListPartial", gameCards)); } }
public void Sort(SortingTypes s) { if (s == SortingTypes.ByRank) { cards.Sort(new SortByRank()); } else { cards.Sort(new SortBySuit()); } }
public void StarSorting() { sortingType = (SortingTypes)dropDown.value; switch (sortingType) { case SortingTypes.BubbleSort: StartCoroutine(BubbleSorting()); break; case SortingTypes.ShakerSort: StartCoroutine(ShakerSorting()); break; case SortingTypes.CombSort: StartCoroutine(CombSorting()); break; case SortingTypes.InsertionSort: StartCoroutine(InsertionSorting()); break; case SortingTypes.GnomeSort: StartCoroutine(GnomeSorting()); break; case SortingTypes.TreeSort: StartCoroutine(TreeSorting()); break; case SortingTypes.QuickSort: StartCoroutine(QuickSorting()); break; case SortingTypes.SelectionSort: StartCoroutine(SelectionSorting()); break; case SortingTypes.HeapSort: StartCoroutine(HeapSorting()); break; case SortingTypes.Counting: StartCoroutine(CountingSorting()); break; default: break; } }
public void Sort(SortingTypes i_Type, SortingByTypes i_SortByType, UserOrderClS i_UserDefinedOrders) { this._SortingType = i_Type; this._SortByType = i_SortByType; this._UserDefinedValues = i_UserDefinedOrders; if (this._SortByType == SortingByTypes.UserDefinedOrder && (i_UserDefinedOrders == null || i_UserDefinedOrders.OrderValues.Count == 0)) { return; } if (this._SortByType != SortingByTypes.None) //2009-3-11 10:16:57@Simon { this.InnerList.Sort(this); } }
public ISortingAlgorithm <T> Get <T>(SortingTypes sortingTypes, IComparer <T> comparer) { switch (sortingTypes) { case SortingTypes.Bubble: return(new BubbleSort <T>(comparer)); case SortingTypes.Insertion: return(new InsertionSort <T>(comparer)); case SortingTypes.Selection: return(new SelectionSort <T>(comparer)); case SortingTypes.Merge: return(new MergeSort <T>(comparer)); case SortingTypes.Quick_LastPivot: return(new QuickSortLastPivot <T>(comparer)); case SortingTypes.Heap: return(new HeapSort <T>(comparer)); case SortingTypes.Shell: return(new ShellSort <T>(comparer)); case SortingTypes.Tim: return(new TimSort <T>(comparer)); case SortingTypes.Comb: return(new CombSort <T>(comparer)); case SortingTypes.Cocktail: return(new CocktailSort <T>(comparer)); case SortingTypes.Pancake: return(new PancakeSort <T>(comparer)); case SortingTypes.Bitonic: return(new BitonicSort <T>(comparer)); default: throw new NotImplementedException(sortingTypes.ToString()); } }
private IEnumerable <Meeting> SetListSorted(List <Meeting> meetings, SortingTypes type, bool onlyToday = false) { var sortedList = onlyToday ? SetTodaysMeetings(meetings) : meetings; if (null != sortedList && sortedList.Any()) { switch (type) { case SortingTypes.NameAZ: sortedList = Castings.CustomToList(sortedList.OrderBy(m => m.GroupName)); break; case SortingTypes.NameZA: sortedList = Castings.CustomToList(sortedList.OrderByDescending(m => m.GroupName)); break; case SortingTypes.TimeEarlyToLate: var sortedMeetings = (from meeting in sortedList from day in meeting.DayAndTime where day.StartTime.Ticks > 0 orderby day.StartTime.Ticks select meeting).ToList().Distinct(); sortedList = onlyToday ? SetTodaysMeetings(Castings.CustomToList(sortedMeetings)) : Castings.CustomToList(sortedMeetings); break; case SortingTypes.TimeLateToEarly: var sortedMeetingList = (from meeting in sortedList from day in meeting.DayAndTime where day.StartTime.Ticks > 0 orderby day.StartTime.Ticks descending select meeting).ToList().Distinct(); sortedList = onlyToday ? SetTodaysMeetings(Castings.CustomToList(sortedMeetingList)) : Castings.CustomToList(sortedMeetingList); break; } } return(sortedList); }
public static string[] ComputeArrayWithoutDelegate(string[] data, SortingTypes sortingType) { // Do some stuff on the array // Order the array switch (sortingType) { case SortingTypes.BubbleSort: data = SortingAlgorithms.BubbleSort(data); break; case SortingTypes.QuickSort: data = SortingAlgorithms.QuickSort(data); break; case SortingTypes.InsertionSort: data = SortingAlgorithms.InsertionSort(data); break; } // Do other stuff on the array return(data); }
private static void CheckConditionToAddButtonToList(ref UIAlertController sortAlertController, ref String message, UIAlertAction alertAction, SortingTypes sortingType) { if (NSUserDefaults.StandardUserDefaults.IntForKey(UserDefaultsKeys.SortingType) != (int)sortingType) { sortAlertController.AddAction(alertAction); } else { message += alertAction.Title; } }
public HorizontalGridData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { try { _SortingField = info.GetString("_SortingByField"); } catch { _SortingField = string.Empty; } try { _SortingBy = (SortingByTypes)info.GetValue("_SortingByType", typeof(SortingByTypes)); } catch { _SortingBy = SortingByTypes.DateTime; } try { _Sorting = (SortingTypes)info.GetValue("_SortingType", typeof(SortingTypes)); } catch { _Sorting = SortingTypes.Descending; } try { _FieldTitle = info.GetString("_FieldTitle"); } catch { _FieldTitle = string.Empty; } try { _UnitsTitle = info.GetString("_UnitsTitle"); } catch { _UnitsTitle = string.Empty; } try { _TopCount = info.GetInt32("_TopCount"); } catch { _TopCount = 7; } try { _DateFormat = info.GetString("_DateFormat"); } catch { _DateFormat = @"M/d/yy"; } }
public void AddMenuItem(string title, ConsoleColor color = ConsoleColor.White, ConsoleColor errorColor = ConsoleColor.Red, int spacing = 14, bool showCursor = true, ErrorProfile errorProfile = null, SortingTypes sortingType = default) { MenuItem newItem = new MenuItem(" " + title, color, errorColor, spacing, showCursor, errorProfile, sortingType); menuItems = AddItemToArray(newItem, menuItems); menuItemsAmount = menuItems.Length; }
/// <summary> /// Sorts input based on <see cref="SortingTypes"/> and <see cref="DefaultSortingAlgorithmFactory"/> /// </summary> /// <param name="sort">ISort</param> /// <param name="sortingTypes"><see cref="SortingTypes"/></param> /// <param name="input">input</param> /// <param name="comparer"><see cref="IComparer{T}"/></param> /// <returns>sorted input</returns> internal static string Sort(this ISorting sort, SortingTypes sortingTypes, string input, IComparer <char> comparer = null) { return(sort.Sort(new DefaultSortingAlgorithmFactory(), sortingTypes, input, comparer)); }
/// <summary> /// Sorts input based on <see cref="SortingTypes"/> and <see cref="ISortingAlgorithmFactory"/> /// </summary> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory"><see cref="ISortingAlgorithmFactory"/></param> /// <param name="sortingTypes"><see cref="SortingTypes"/></param> /// <param name="input">input</param> /// <param name="comparer"><see cref="IComparer{T}"/></param> /// <returns>sorted input</returns> internal static string Sort(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, SortingTypes sortingTypes, string input, IComparer <char> comparer = null) { if (string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input)) { return(input); } var charArray = input.ToCharArray(); var sorter = sortingAlgorithmFactory.Get <char>(sortingTypes, comparer != null ? comparer : new AsciiValueComparer()); sorter.Sort(charArray); input = new string(charArray); return(input); }
/// <summary> /// Sorts input based on the <see cref="SortingTypes"/> using <see cref="DefaultSortingAlgorithmFactory"/> /// </summary> /// <typeparam name="T">Type of input</typeparam> /// <param name="sort">ISort</param> /// <param name="sortingTypes"><see cref="SortingTypes"/></param> /// <param name="input">input</param> /// <param name="comparer"><see cref="IComparer{T}"/></param> internal static void Sort <T>(this ISorting sort, SortingTypes sortingTypes, T[] input, IComparer <T> comparer) { sort.Sort <T>(new DefaultSortingAlgorithmFactory(), sortingTypes, input, comparer); }
/// <summary> /// Sorts input based on the <see cref="SortingTypes"/> and <see cref="ISortingAlgorithmFactory"/> /// </summary> /// <typeparam name="T">Type of input</typeparam> /// <param name="sort">ISort</param> /// <param name="sortingAlgorithmFactory"><see cref="ISortingAlgorithmFactory"/></param> /// <param name="sortingTypes"><see cref="SortingTypes"/></param> /// <param name="input">input</param> /// <param name="comparer"><see cref="IComparer{T}"/></param> internal static void Sort <T>(this ISorting sort, ISortingAlgorithmFactory sortingAlgorithmFactory, SortingTypes sortingTypes, T[] input, IComparer <T> comparer) { var sorter = sortingAlgorithmFactory.Get <T>(sortingTypes, comparer); sorter.Sort(input); }
public IEnumerable <Meeting> GetListSorted(List <Meeting> meetings, SortingTypes type, bool onlyToday = false) { return(SetListSorted(meetings, type, onlyToday)); }
public void SetSortingType(int id) { sortingType = (SortingTypes)id; }
public IndexCompare(SortingTypes i_SortingType) { this.SortingType = i_SortingType; }
protected override void LoadDefaults() { showModules = false; groupNamespaces = true; useColumns = true; sortingType = SortingTypes.OriginalNameAscending; visualStudioVersion = VSOpener.HighestVersion; showOriginal = true; showUnicode = false; simplifySystemNames = true; simplifyNullable = true; }