/// <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())); }
/// <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> /// <param name="options"></param> /// <param name="comparer">Comparer for type T</param> /// <returns></returns> public static SearchOptions <T> UseTernarySearch <T>(this SearchOptions <T> options, Func <T, T, int> comparer) { return(options.UseTernarySearch(new LambdaComparer <T>(comparer))); }