예제 #1
0
 /// <summary>
 ///     Performs search using BinarySearch algorithm. Input list needs to be SORTED.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(Log(n))
 ///     Average:    O(Log(n))
 /// </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 SearchOptions <T> UseBinarySearch <T>(this SearchOptions <T> options, IComparer <T> comparer)
 {
     return(new SearchOptions <T>(new BinarySearch <T>(comparer)));
 }
예제 #2
0
 /// <summary>
 ///     Performs search using TernarySearch algorithm. Input list needs to be SORTED.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(Log(n))
 ///     Average:    O(Log(n))
 /// </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 SearchOptions <T> UseTernarySearch <T, TComparer>(this SearchOptions <T> options) where TComparer : IComparer <T>, new()
 {
     return(options.UseTernarySearch(new TComparer()));
 }
예제 #3
0
 /// <summary>
 ///     Performs search using BinarySearch algorithm. Input list needs to be SORTED.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(Log(n))
 ///     Average:    O(Log(n))
 /// </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 SearchOptions <T> UseBinarySearch <T>(this SearchOptions <T> options, Func <T, T, int> comparer)
 {
     return(options.UseBinarySearch(new LambdaComparer <T>(comparer)));
 }
예제 #4
0
 /// <summary>
 ///     Performs search using HashTable.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(n)
 ///     Average:    O(n)
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <returns></returns>
 public static SearchOptions <T> UseHashTableSearch <T>(this SearchOptions <T> options)
 {
     return(new SearchOptions <T>(new HashSearch <T>()));
 }
예제 #5
0
 /// <summary>
 ///     Performs search using FibonacciSearch algorithm. Input list needs to be SORTED.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(log(n))
 ///     Average:    O(log(n))
 /// </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 SearchOptions <T> UseFibonacciSearch <T>(this SearchOptions <T> options, IComparer <T> comparer)
 {
     return(new SearchOptions <T>(new FibonacciSearch <T>(comparer)));
 }
예제 #6
0
 /// <summary>
 ///     Performs search using ExponentialSearch algorithm. Input list needs to be SORTED.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(log(n))
 ///     Average:    O(log(n))
 /// </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 SearchOptions <T> UseExponentialSearch <T>(this SearchOptions <T> options, IComparer <T> comparer)
 {
     return(new SearchOptions <T>(new ExponentialSearch <T>(comparer)));
 }
예제 #7
0
 /// <summary>
 ///     Performs search using Linear Search algorithm.
 ///     Performance:
 ///     Best:       O(1)
 ///     Worst:      O(n)
 ///     Average:    O(1)
 /// </summary>
 /// <typeparam name="T">Type contained in the collection</typeparam>
 /// <param name="options"></param>
 /// <returns></returns>
 public static SearchOptions <T> UseLinearSearch <T>(this SearchOptions <T> options)
 {
     return(SearchOptions <T> .Default());
 }