binary_search2.rb
# Find first interval containing point +x+.
# @return [Segment|NilClass]
Find first interval containing point +x+.
Find first interval containing point + x + .
def find(x)
    return nil if x.nil?
    low = 0
    high = @segments.size - 1
    while low <= high
      mid = (low + high) / 2
      case matches?(x, low, high, mid)
        when -1 then high = mid - 1
        when 1 then low = mid + 1
        when 0 then return @segments[mid]
        else return nil
      end
    end
    nil
  end
def find ( x ) return nil if x . nil? low = 0 high = @segments . size - 1 while low <= high mid = ( low + high ) / 2 case matches? ( x , low , high , mid ) when - 1 then high = mid - 1 when 1 then low = mid + 1 when 0 then return @segments [ mid ] else return nil end end nil end
Find first interval containing point +x+.
Find first interval containing point + x + .
None
Segment|NilClass
x
<not_specific>