Exemple #1
0
 /// <summary>
 ///     Performs sort using Shell Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <param name="comparer">Comparer for type T</param>
 /// <param name="incrementFactory">Factory function for calculating custom Increment Step to optimize sorting</param>
 /// <returns></returns>
 public static SortOptions <T> UseShellSort <T>(this SortOptions <T> options, IComparer <T> comparer, Func <IList <T>, int> incrementFactory)
 {
     if (comparer == null)
     {
         throw new ArgumentNullException(nameof(comparer));
     }
     if (incrementFactory == null)
     {
         throw new ArgumentNullException(nameof(incrementFactory));
     }
     return(new SortOptions <T>(new ShellSortStrategy <T>(comparer, incrementFactory)));
 }
Exemple #2
0
 /// <summary>
 ///     Performs sort using Insertion Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <param name="comparer">Lambda based comparer for type T</param>
 /// <returns></returns>
 public static SortOptions <T> UseInsertionSort <T>(this SortOptions <T> options, Func <T, T, int> comparer)
 {
     return(options.UseInsertionSort(new LambdaComparer <T>(comparer)));
 }
Exemple #3
0
 /// <summary>
 ///     Performs sort using Insertion Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <typeparam name="TComparer">IComparer implementation for type T</typeparam>
 /// <param name="options"></param>
 /// <returns></returns>
 public static SortOptions <T> UseInsertionSort <T, TComparer>(this SortOptions <T> options)
     where TComparer : IComparer <T>, new()
 {
     return(options.UseInsertionSort(new TComparer()));
 }
Exemple #4
0
 /// <summary>
 ///     Performs sort using Bubble Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <param name="comparer">Comparer for type T</param>
 /// <returns></returns>
 public static SortOptions <T> UseBubbleSort <T>(this SortOptions <T> options, IComparer <T> comparer)
 {
     return(new SortOptions <T>(new BubbleSortStrategy <T>(comparer)));
 }
Exemple #5
0
 /// <summary>
 ///     Performs sort using Shell Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <param name="comparer">Comparer for type T</param>
 /// <returns></returns>
 public static SortOptions <T> UseShellSort <T>(this SortOptions <T> options, IComparer <T> comparer)
 {
     return(options.UseShellSort(comparer, collection => collection.Count / 2));
 }
Exemple #6
0
 /// <summary>
 ///     Performs sort using Shell Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <param name="comparer">Lambda based comparer for type T</param>
 /// <param name="incrementFactory">Factory function for calculating custom Increment Step to optimize sorting</param>
 /// <returns></returns>
 public static SortOptions <T> UseShellSort <T>(this SortOptions <T> options, Func <T, T, int> comparer, Func <IList <T>, int> incrementFactory)
 {
     return(options.UseShellSort(new LambdaComparer <T>(comparer), incrementFactory));
 }
Exemple #7
0
 /// <summary>
 ///     Performs sort using Shell Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <param name="comparer">Lambda based comparer for type T</param>
 /// <returns></returns>
 public static SortOptions <T> UseShellSort <T>(this SortOptions <T> options, Func <T, T, int> comparer)
 {
     return(options.UseShellSort(new LambdaComparer <T>(comparer), collection => collection.Count / 2));
 }
Exemple #8
0
 /// <summary>
 ///     Performs sort using Shell Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <typeparam name="TComparer">IComparer implementation for type T</typeparam>
 /// <param name="options"></param>
 /// <param name="incrementFactory">Factory function for calculating custom Increment Step to optimize sorting</param>
 /// <returns></returns>
 public static SortOptions <T> UseShellSort <T, TComparer>(this SortOptions <T> options, Func <IList <T>, int> incrementFactory)
     where TComparer : IComparer <T>, new()
 {
     return(options.UseShellSort(new TComparer(), incrementFactory));
 }
Exemple #9
0
 /// <summary>
 ///     Performs sort using Shell Sort algorithm.
 ///     Performance:
 ///     Best:       O(n)
 ///     Worst:      O(n*n)
 ///     Average:    O(n*n)
 ///     In Place
 ///     Stable
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <typeparam name="TComparer">IComparer implementation for type T</typeparam>
 /// <param name="options"></param>
 /// <returns></returns>
 public static SortOptions <T> UseShellSort <T, TComparer>(this SortOptions <T> options)
     where TComparer : IComparer <T>, new()
 {
     return(options.UseShellSort(new TComparer(), collection => collection.Count / 2));
 }