Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/10/14 10:18:35 (10 years ago)
Author:
gkronber
Message:

#2106: changed methods for sorting in ObservableArray and ObservableList to use a stable sort (via Enumerable.OrderBy()). This is implemented as extension methods in HeuristicLab.Common. This implementation requires additional memory O(n).
The unit tests for tabu search had to be updated as the stable sort changes the results of the sample.
(minor bug fix in TestRandom)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Collections/3.3/ObservableList.cs

    r9456 r10324  
    2525using System.ComponentModel;
    2626using System.Linq;
     27using HeuristicLab.Common;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2829
     
    320321      if (list.Count > 1) {
    321322        IndexedItem<T>[] oldItems = GetIndexedItems();
    322         list.Sort();
     323        list.StableSort();
    323324        OnItemsMoved(GetIndexedItems(), oldItems);
    324325        OnPropertyChanged("Item[]");
     
    328329      if (list.Count > 1) {
    329330        IndexedItem<T>[] oldItems = GetIndexedItems();
    330         list.Sort(comparison);
     331        list.StableSort(comparison);
    331332        OnItemsMoved(GetIndexedItems(), oldItems);
    332333        OnPropertyChanged("Item[]");
     
    336337      if (list.Count > 1) {
    337338        IndexedItem<T>[] oldItems = GetIndexedItems();
    338         list.Sort(comparer);
     339        list.StableSort(comparer);
    339340        OnItemsMoved(GetIndexedItems(), oldItems);
    340341        OnPropertyChanged("Item[]");
     
    344345      if (count > 1) {
    345346        IndexedItem<T>[] oldItems = GetIndexedItems(index, count);
    346         list.Sort(index, count, comparer);
     347        list.StableSort(index, count, comparer);
    347348        OnItemsMoved(GetIndexedItems(index, count), oldItems);
    348349        OnPropertyChanged("Item[]");
Note: See TracChangeset for help on using the changeset viewer.