public void AddSortedWithoutNotification(T item, IDecideWhichIsLess <T> comparer = null) { RunActionWithoutNotification ( () => { AddSorted(item, comparer); } ); }
/// <summary> /// Adds the sorted. /// </summary> /// <param name="item">The item.</param> /// <param name="comparer">The comparer.</param> public void AddSorted(T item, IDecideWhichIsLess <T> comparer = null) { if (comparer == null) { Add(item); return; } var i = 0; while ((i < Count) && comparer.IsLessThan(item, this[i])) { i++; } Insert(i, item); }
/// <summary> /// Adds the range sorted and without notification. /// </summary> /// <param name="list">The list.</param> /// <param name="comparer">The comparer.</param> public void AddRangeSortedAndWithoutNotification(T[] list, IDecideWhichIsLess <T> comparer = null) { ErrorUtils.IssueArgumentErrorIfTrue (list.IsAnEmptyList(), nameof(BetterObservableCollection <T>) + ": " + nameof(AddRangeSortedAndWithoutNotification) + " requires a valid list"); RunActionWithoutNotification ( () => { foreach (var item in list) { AddSorted(item, comparer); } } ); }