Module: Patches::PatchIntervalTree::ForNode

Included in:
IntervalTree::Node
Defined in:
lib/patches/patch_interval_tree.rb

Instance Method Summary collapse

Instance Method Details

#search_s_center(query) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/patches/patch_interval_tree.rb', line 64

def search_s_center(query)
  s_center.select do |range|
    # when this range is smaller than and not overlaps with `query`
    #      range          query
    #   |---------|    |---------|
    if query.begin and range.end
      next false if query.begin > range.end
      next false if query.begin == range.end and range.exclude_end?
    end

    # when this range is larger than and not overlaps with `query`
    #      query          range
    #   |---------|    |---------|
    if query.end and range.begin
      next false if query.end < range.begin
      next false if query.end == range.begin and query.exclude_end?
    end

    next true
  end
end