(int_, ranges)
return False
Determine if `int_` falls into one of the ranges in `ranges`.
Determine if `int_` falls into one of the ranges in `ranges`.
Determine if int_ falls into one of the ranges in ranges .
def intranges_contain(int_, ranges):
    """Determine if `int_` falls into one of the ranges in `ranges`."""
    tuple_ = _encode_range(int_, 0)
    pos = bisect.bisect_left(ranges, tuple_)
    # we could be immediately ahead of a tuple (start, end)
    # with start < int_ <= end
    if pos > 0:
        left, right = _decode_range(ranges[pos-1])
        if left <= int_ < right:
            return True
    # or we could be immediately behind a tuple (int_, end)
    if pos < len(ranges):
        left, _ = _decode_range(ranges[pos])
        if left == int_:
            return True
    return False
def intranges_contain ( int_ , ranges ) : tuple_ = _encode_range ( int_ , 0 ) pos = bisect . bisect_left ( ranges , tuple_ ) # we could be immediately ahead of a tuple (start, end) # with start < int_ <= end if pos > 0 : left , right = _decode_range ( ranges [ pos - 1 ] ) if left <= int_ < right : return True # or we could be immediately behind a tuple (int_, end) if pos < len ( ranges ) : left , _ = _decode_range ( ranges [ pos ] ) if left == int_ : return True return False