private List <QuickSortGroup> GetGroups(IEnumerable <SignitureItem> items) { Dictionary <int, List <SignitureItem> > dictionary = new Dictionary <int, List <SignitureItem> >(); foreach (SignitureItem item in items) { if (dictionary.ContainsKey(item.Rank)) { dictionary[item.Rank].Add(item); } else { dictionary.Add(item.Rank, new List <SignitureItem>() { item }); } } List <QuickSortGroup> ret = new List <QuickSortGroup>(); foreach (List <SignitureItem> item in dictionary.Values) { List <SignitureItem> unsortedSet = item.ToList(); SignitureItem pivotItem = unsortedSet[0]; unsortedSet.RemoveAt(0); QuickSortGroup group = new QuickSortGroup(pivotItem, unsortedSet, pivotItem.Rank, this); ret.Add(group); } return(ret); }
public MitosisResult UndergoMitosis() { int baseRank = _rankOffset + _worseLines.Count; PivotItem.Rank = baseRank; QuickSortGroup betterGroup = GetGroupFrom(_betterLines, baseRank + 1); QuickSortGroup worseGroup = GetGroupFrom(_worseLines, _rankOffset); _betterLines.Clear(); _worseLines.Clear(); return(new MitosisResult(betterGroup, worseGroup)); }
public void UndergoMitosis(QuickSortGroup completedGroup) { MitosisResult result = completedGroup.UndergoMitosis(); if (result.BetterGroup != null) { _groups.Add(result.BetterGroup); } if (result.WorseGroup != null) { _groups.Add(result.WorseGroup); } }
private void UpdateCurrentFight() { _currentGroup = _sorter.Groups.FirstOrDefault(item => !item.Complete); NotifyPropertyChanged(nameof(CurrentGroup)); NotifyPropertyChanged(nameof(Items)); if (_currentGroup != null) { _currentFight = _currentGroup.GetNextPhraseFight(); } else { _currentFight = null; } NotifyPropertyChanged(nameof(CurrentFight)); }
public MitosisResult(QuickSortGroup betterGroup, QuickSortGroup worseGroup) { BetterGroup = betterGroup; WorseGroup = worseGroup; }