Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/05/20 05:46:07 (4 years ago)
Author:
abeham
Message:

#2521: completed port of VRP (needs testing though)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/ObservableCollection.cs

    r17461 r17718  
    103103        if (list.Capacity != capacity)
    104104          OnPropertyChanged("Capacity");
    105         OnPropertyChanged("Item[]");
    106         OnPropertyChanged("Count");
    107       }
     105        OnPropertyChanged("Count");
     106      }
     107    }
     108
     109    /// <summary>
     110    /// Performs a Clear and an AddRange, but does not fire separate events for those operations
     111    /// </summary>
     112    /// <param name="collection"></param>
     113    public void Replace(IEnumerable<T> collection) {
     114      List<T> oldItems = null;
     115      if (list.Any()) oldItems = new List<T>(list);
     116      else oldItems = new List<T>();
     117
     118      int oldCapacity = list.Capacity;
     119      list.Clear();
     120      list.AddRange(collection);
     121
     122      List<T> items = null;
     123      if (list.Any()) items = new List<T>(list);
     124      else items = new List<T>();
     125
     126      OnCollectionReset(items, oldItems);
     127      if (oldCapacity != list.Capacity) OnPropertyChanged("Capacity");
     128      if (oldItems.Count != items.Count) OnPropertyChanged("Count");
    108129    }
    109130
Note: See TracChangeset for help on using the changeset viewer.