Changeset 6342 for trunk/sources/HeuristicLab.Collections
- Timestamp:
- 05/30/11 18:07:32 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources
- Property svn:mergeinfo changed
/branches/histogram (added) merged: 5959,5961,5970,5994-5996,5999,6007,6010-6016,6020,6022,6027-6028,6032,6046,6055-6056,6081-6082,6086-6087,6089,6115,6176,6194-6195,6338-6341
- Property svn:mergeinfo changed
-
trunk/sources/HeuristicLab.Collections/3.3/ObservableList.cs
r5445 r6342 24 24 using System.Collections.Generic; 25 25 using System.ComponentModel; 26 using System.Linq; 26 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 28 … … 211 212 } 212 213 214 /// <summary> 215 /// Performs a Clear and an AddRange, but does not fire separate events for those operations 216 /// </summary> 217 /// <param name="collection"></param> 218 public void Replace(IEnumerable<T> collection) { 219 List<IndexedItem<T>> oldItems = null; 220 if (list.Any()) oldItems = list.Select((x, i) => new IndexedItem<T>(i, x)).ToList(); 221 else oldItems = new List<IndexedItem<T>>(); 222 223 int oldCapacity = list.Capacity; 224 list.Clear(); 225 list.AddRange(collection); 226 227 List<IndexedItem<T>> items = null; 228 if (list.Any()) items = list.Select((x, i) => new IndexedItem<T>(i, x)).ToList(); 229 else items = new List<IndexedItem<T>>(); 230 231 if (oldCapacity != list.Capacity) OnPropertyChanged("Capacity"); 232 OnPropertyChanged("Item[]"); 233 if (oldItems.Count != items.Count) OnPropertyChanged("Count"); 234 OnItemsReplaced(items, oldItems); 235 } 236 213 237 public bool Remove(T item) { 214 238 int index = list.IndexOf(item);
Note: See TracChangeset
for help on using the changeset viewer.