/// <summary> /// A method of sorting matrix rows depending on the sort criterion. /// </summary> /// <param name="criterion">A parameter defining specific sort type.</param> /// <returns>Matrix.</returns> public Matrix Sort(SortCriterion criterion) { switch (criterion) { case SortCriterion.AscByMax: return(new AscendingByMax().SortMatrix(this)); case SortCriterion.AscByMin: return(new AscendingByMin().SortMatrix(this)); case SortCriterion.AscBySum: return(new AscendingBySum().SortMatrix(this)); case SortCriterion.DescByMax: return(new DescendingByMax().SortMatrix(this)); case SortCriterion.DescByMin: return(new DescendingByMin().SortMatrix(this)); case SortCriterion.DescBySum: return(new DescendingBySum().SortMatrix(this)); default: throw new ArgumentException(); } }
public LastUsedValues GetLastUsedValues() { int? catId = _settingsService.GetSettings <int?>(SettingKey.LastGoodsCategory.ToString()); int? manId = _settingsService.GetSettings <int?>(SettingKey.LastGoodsManufacturer.ToString()); int? supId = _settingsService.GetSettings <int?>(SettingKey.LastGoodsSupplier.ToString()); SortCriterion sortBy = _settingsService.GetSettings <SortCriterion>(SettingKey.LastGoodsSortBy.ToString()); LastUsedValues values = new LastUsedValues() { LastSortBy = sortBy }; if (catId.HasValue) { var cat = _shopCategoryService.CategoryExists(catId.Value) ? _shopCategoryService.GetCategory(catId.Value) : null; if (cat == null) { _settingsService.Set <int?>(SettingKey.LastGoodsCategory.ToString(), null); } else { values.LastCategory = new IdNamePair <int>(cat.HeartId, cat.Name); } } if (supId.HasValue) { var man = _manufacturerService.GetManufacturer(supId.Value); if (man == null) { _settingsService.Set <int?>(SettingKey.LastGoodsManufacturer.ToString(), null); } else { values.LastSupplier = new IdNamePair <int>(man.HeartId, man.Name); } } if (manId.HasValue) { var man = _manufacturerService.GetManufacturer(manId.Value); if (man == null) { _settingsService.Set <int?>(SettingKey.LastGoodsManufacturer.ToString(), null); } else { values.LastManufacturer = new IdNamePair <int>(man.HeartId, man.Name); } } return(values); }
public void Constructor_DoesNotThrow( [Values(SortOrder.Ascending, SortOrder.Descending)] SortOrder sortOrder) { SortCriterion <TestEntity, int> criterion = null; Assert.DoesNotThrow( () => criterion = new SortCriterion <TestEntity, int>(e => e.Id, sortOrder)); Assert.That(criterion.SortPropertySelector, Is.Not.Null); Assert.That(criterion.SortOrder, Is.EqualTo(sortOrder)); }
public void Apply_DoesNotThrow( [Values(SortOrder.Ascending, SortOrder.Descending)] SortOrder sortOrder) { var queryData = TestData.DeepCopyTestEntityData().AsQueryable(); var criterion = new SortCriterion <TestEntity, int>(e => e.Id, sortOrder); Assert.DoesNotThrow(() => criterion.Apply(queryData)); // We cannot mock extension methods so cannot verify which query method was called. }
private static void SortSheet(SmartsheetClient smartsheet, long sheetId) { Sheet sheet = smartsheet.SheetResources.GetSheet(sheetId, null, null, null, null, null, null, null); SortSpecifier specifier = new SortSpecifier(); SortCriterion criterion = new SortCriterion(); criterion.ColumnId = (long)sheet.Columns[0].Id; criterion.Direction = SortDirection.DESCENDING; specifier.SortCriteria = new SortCriterion[] { criterion }; sheet = smartsheet.SheetResources.SortSheet(sheetId, specifier); Assert.AreEqual(sheet.Rows[0].Cells[0].DisplayValue, "C"); }
private void TestSortSheet() { Sheet sheet = CreateSheet(); SortSpecifier specifier = new SortSpecifier(); SortCriterion criterion = new SortCriterion(); criterion.ColumnId = sheet.Columns[1].Id.Value; criterion.Direction = SortDirection.DESCENDING; specifier.SortCriteria = new SortCriterion[] { criterion }; sheet = smartsheet.SheetResources.SortSheet(sheet.Id.Value, specifier); Assert.AreEqual(sheet.Rows[0].Cells[1].DisplayValue, "C"); DeleteSheet(sheet.Id.Value); }
private void Sort(SortCriterion criterion, Comparison <UIComponent> compare) { if (m_CurSortCriterion == criterion) { m_InverseSort = !m_InverseSort; } else { m_InverseSort = false; } if (m_ScrollablePanel.components.Count > 0) { OverviewPanelBase.Quicksort(m_ScrollablePanel.components, compare); m_CurSortCriterion = criterion; m_ScrollablePanel.Invalidate(); } }
private Comparison <UIComponent> getSortingMethod(SortCriterion crit) { switch (crit) { case SortCriterion.HGHWTH: return(new Comparison <UIComponent>(CompareHgh)); case SortCriterion.LOWWTH: return(new Comparison <UIComponent>(CompareLow)); case SortCriterion.MEDWTH: return(new Comparison <UIComponent>(CompareMed)); default: case SortCriterion.NAME: return(new Comparison <UIComponent>(CompareNames)); } }
static void Main(string[] args) { Dictionary <string, List <House> > Houses = ReadHousesFromFile("file.txt"); string searchingStreet = ReadSearchingStreet(); if (Houses.ContainsKey(searchingStreet)) { List <House> houses = Houses[searchingStreet]; SortCriterion sortCriterion = ReadSortCriterion(); SortOrder sortOrder = ReadSortOrder(); houses.Sort(new HouseComparer(sortCriterion, sortOrder)); PrintHouses(houses); } else { Console.WriteLine("Улица не найдена"); } Console.ReadLine(); }
public void Sort(SortCriterion sortCriterion) { switch (sortCriterion) { case SortCriterion.WeightSweet: SweetsInGift.Sort((x, y) => x.WeightSingleItemInGrams.CompareTo(y.WeightSingleItemInGrams)); break; case SortCriterion.SugarSweet: SweetsInGift.Sort((x, y) => x.GramsOfSugarSingleItem.CompareTo(y.GramsOfSugarSingleItem)); break; case SortCriterion.NameSweet: SweetsInGift.Sort((x, y) => x.Name.CompareTo(y.Name)); break; default: throw new Exception("This criterion is not available"); } }
public static void SortRows(this int[,] matrix, SortCriterion sortCriterion, SortDirection sortDirection) { TranformFromMatrixToJaggedArray(matrix); matrixRowsKeys = new int[matrix.GetLength(0)]; for (int i = 0; i < matrix.GetLength(0); i++) { if (sortCriterion == SortCriterion.RowSum) matrixRowsKeys[i] = jaggedArray[i].Sum(); if (sortCriterion == SortCriterion.HighestRowElement) matrixRowsKeys[i] = jaggedArray[i].Max(); if (sortCriterion == SortCriterion.LowestRowElement) matrixRowsKeys[i] = jaggedArray[i].Min(); } MatrixSorter.sortDirection = sortDirection; SortRowsByKeys(); TranformFromJaggedArrayToMatrix(matrix); }
/// <summary> /// Convert the results of <see cref="StringSearch"/> (<see cref="IOrderedCriterion"/>) to <see cref="TypeSearch"/>.<see cref="TypeSearch.SortCriteria{T}"/> /// </summary> /// <param name="orderedCriteria"></param> /// <returns></returns> public SortCriteria <T> ConvertTo(IEnumerable <IOrderedCriterion> orderedCriteria) { var sortCriteria = new SortCriteria <T>(); foreach (var orderedCriterion in orderedCriteria) { var sortCriterion = new SortCriterion() { Name = orderedCriterion.Name }; if (orderedCriterion.Direction == OrderByDirection.Ascending) { // Ascending sortCriterion.SortDirection = SortDirection.Ascending; } else { // Descending sortCriterion.SortDirection = SortDirection.Descending; } sortCriteria.Criteria.Add(sortCriterion); } return(sortCriteria); }
private void RefreshOutsideConnections() { if (!OutsideConnectionSettingsManager.exists || !m_Initialized) { return; } OutsideConnectionSettingsManager.instance.SyncWithBuildingManager(); var outsideConnectionCount = 0; foreach (var element in OutsideConnectionSettingsManager.instance.SettingsDict) { OutsideConnectionInfo outsideConnectionInfo; if (outsideConnectionCount >= m_ScrollablePanel.components.Count) { var gameObject = new GameObject("AOCOutsideConnectionInfo", new System.Type[] { typeof(OutsideConnectionInfo) }); outsideConnectionInfo = gameObject.GetComponent <OutsideConnectionInfo>(); outsideConnectionInfo.component.width = m_ScrollablePanel.width - 2; outsideConnectionInfo.eventDetailsOpen += OnDetailsOpened; outsideConnectionInfo.eventNameChanged += OnConnectionNameChanged; m_ScrollablePanel.AttachUIComponent(gameObject); } else { outsideConnectionInfo = m_ScrollablePanel.components[outsideConnectionCount].GetComponent <OutsideConnectionInfo>(); } outsideConnectionInfo.buildingID = element.Key; ++outsideConnectionCount; } m_OutsideConnectionCountLabel.text = m_ScrollablePanel.components.Count.ToString(); m_CurSortCriterion = SortCriterion.DEFAULT; OnTransportTypeSort(); }
/// <summary> /// /// </summary> private bool buildSubObjectList(SortCriterion sortCriterion) { return(sortCriterion.SubObjectTypeField != null); }
public void SetSorting(SortCriterion criteria) { reverseOrder = m_LastSortCriterionLines == criteria ? !reverseOrder : false; m_LastSortCriterionLines = criteria; ReSort(); }
private FileSystemObjectComparer(SortCriterion criterion, bool prioritizeDirectories) { Criterion = criterion; DirectoriesFirst = prioritizeDirectories; }
public HouseComparer(SortCriterion sortCriterion, SortOrder sortOrder) { this.sortCriterion = sortCriterion; this.sortOrder = sortOrder; }