Project

General

Profile

« Previous | Next » 

Revision 7d08dbd0

Added by kyanagi (Kouhei Yanagita) almost 2 years ago

Optimize Range#bsearch for beginless/endless ranges

On Range#bsearch for endless ranges, we try positions at begin + 2**i (i = 0, 1, 2, ...)
to find a point that satisfies a given condition.
Subsequently, we perform binary searching with the interval [begin, begin + 2**n].

However, the interval [begin + 2**(n-1), begin + 2**n] is sufficient for binary search
because begin + 2**(n-1) does not satisfy the condition.

The same applies to beginless ranges.