Exemplo n.º 1
0
 public void AddSortedWithoutNotification(T item, IDecideWhichIsLess <T> comparer = null)
 {
     RunActionWithoutNotification
     (
         () => { AddSorted(item, comparer); }
     );
 }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
                }
            }
            );
        }