public KeyValueCollection(IReadOnlyCollection <KeyValuePair <TKey, TObject> > items, IComparer <KeyValuePair <TKey, TObject> > comparer, SortReason sortReason, SortOptimisations optimisations)
 {
     _items        = items ?? throw new ArgumentNullException(nameof(items));
     Comparer      = comparer;
     SortReason    = sortReason;
     Optimisations = optimisations;
 }
Beispiel #2
0
 public Sorter(SortOptimisations optimisations,
               IComparer <TObject> comparer = null,
               int resetThreshold           = -1)
 {
     _optimisations  = optimisations;
     _resetThreshold = resetThreshold;
     _comparer       = new KeyValueComparer <TObject, TKey>(comparer);
 }
Beispiel #3
0
 public KeyValueCollection(IEnumerable<KeyValuePair<TKey, TObject>> items,
                           IComparer<KeyValuePair<TKey, TObject>> comparer,
                           SortReason sortReason,
                           SortOptimisations optimisations)
 {
     if (items == null) throw new ArgumentNullException(nameof(items));
     _items = items.ToList();
     Comparer = comparer;
     SortReason = sortReason;
     Optimisations = optimisations;
 }
Beispiel #4
0
        public Sort(IObservable <IChangeSet <TObject, TKey> > source, IComparer <TObject>?comparer, SortOptimisations sortOptimisations = SortOptimisations.None, IObservable <IComparer <TObject> >?comparerChangedObservable = null, IObservable <Unit>?resorter = null, int resetThreshold = -1)
        {
            if (comparer is null && comparerChangedObservable is null)
            {
                throw new ArgumentException("Must specify comparer or comparerChangedObservable");
            }

            _source                    = source ?? throw new ArgumentNullException(nameof(source));
            _comparer                  = comparer;
            _sortOptimisations         = sortOptimisations;
            _resorter                  = resorter;
            _comparerChangedObservable = comparerChangedObservable;
            _resetThreshold            = resetThreshold;
        }
Beispiel #5
0
 public static IObservable <IChangeSet <TObj, TKey> > Sort <TObj, TRhs, TKey>(
     this IObservable <IChangeSet <TObj, TKey> > obs,
     Func <TObj, TRhs> selector,
     IObservable <IComparer <TRhs> > comparer,
     SortOptimisations sortOptimisations = SortOptimisations.None,
     int resetThreshold          = 100,
     IObservable <Unit>?resorter = null)
     where TKey : notnull
     where TRhs : notnull
 {
     if (resorter == null)
     {
         return(obs.Sort(comparer.Select(x => new Comparer <TObj, TRhs>(selector, x)), sortOptimisations, resetThreshold));
     }
     else
     {
         return(obs.Sort(comparer.Select(x => new Comparer <TObj, TRhs>(selector, x)), resorter, sortOptimisations, resetThreshold));
     }
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public IndexCalculator(KeyValueComparer <TObject, TKey> comparer, SortOptimisations optimisations)
 {
     _comparer      = comparer;
     _optimisations = optimisations;
     _list          = new List <KeyValuePair <TKey, TObject> >();
 }
Beispiel #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 public IndexCalculator(KeyValueComparer <TObject, TKey> comparer, SortOptimisations optimisations)
 {
     _comparer      = comparer;
     _optimisations = optimisations;
     _list          = ImmutableList <KeyValuePair <TKey, TObject> > .Empty;
 }
 public KeyValueCollection()
 {
     _optimisations = SortOptimisations.None;
     _items         = new List <KeyValuePair <TKey, TObject> >();
     _comparer      = new KeyValueComparer <TObject, TKey>();
 }