コード例 #1
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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)));
 }
コード例 #2
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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)));
 }
コード例 #3
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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()));
 }
コード例 #4
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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)));
 }
コード例 #5
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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));
 }
コード例 #6
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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));
 }
コード例 #7
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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));
 }
コード例 #8
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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));
 }
コード例 #9
0
ファイル: SortOptionsExtensions.cs プロジェクト: agecas/DSAA
 /// <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));
 }