Esempio n. 1
0
        public static LongRange BinSearch(LongRange range, Func <long, bool> isBigger, Func <LongRange, bool> stopCondition)
        {
            if (stopCondition(range))
            {
                return(range);
            }
            var middle = range.Left + (range.Right - range.Left) / 2;

            return(isBigger(middle) ? BinSearch(new LongRange(range.Left, middle), isBigger, stopCondition)
                : BinSearch(new LongRange(middle, range.Right), isBigger, stopCondition));
        }
Esempio n. 2
0
 public static LongRange BinSearch(LongRange range, Func <long, bool> isBigger, long width) => BinSearch(range, isBigger, x => range.Right - range.Left < width);