Class: IntervalNotation::SweepLine::TraceState::Union
- Inherits:
-
Struct
- Object
- Struct
- IntervalNotation::SweepLine::TraceState::Union
- Defined in:
- lib/interval_notation/sweep_line/trace_state/union.rb
Overview
Class allows to observe whether sweep line is inside of interval sets union or outside
Instance Attribute Summary collapse
-
#num_covered ⇒ Object
Returns the value of attribute num_covered.
Class Method Summary collapse
Instance Method Summary collapse
-
#state_after_point(points_on_place) ⇒ Object
map state at point into state after point.
-
#state_at_point(points_on_place) ⇒ Object
map state before point into state at point.
- #state_convolution ⇒ Object
Instance Attribute Details
#num_covered ⇒ Object
Returns the value of attribute num_covered
6 7 8 |
# File 'lib/interval_notation/sweep_line/trace_state/union.rb', line 6 def num_covered @num_covered end |
Class Method Details
.initial_state(num_interval_sets) ⇒ Object
7 8 9 |
# File 'lib/interval_notation/sweep_line/trace_state/union.rb', line 7 def self.initial_state(num_interval_sets) self.new(0) end |
Instance Method Details
#state_after_point(points_on_place) ⇒ Object
map state at point into state after point
29 30 31 32 33 34 35 36 |
# File 'lib/interval_notation/sweep_line/trace_state/union.rb', line 29 def state_after_point(points_on_place) new_state = num_covered points_on_place.reject(&:singular_point?).each{|point| new_state += point.opening ? 1 : -1 } self.class.new(new_state) end |
#state_at_point(points_on_place) ⇒ Object
map state before point into state at point
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/interval_notation/sweep_line/trace_state/union.rb', line 12 def state_at_point(points_on_place) new_state = num_covered points_on_place.each{|point| if point.singular_point? new_state += 1 else if point.closing && !point.included new_state -= 1 elsif point.opening && point.included new_state += 1 end end } self.class.new(new_state) end |
#state_convolution ⇒ Object
38 39 40 |
# File 'lib/interval_notation/sweep_line/trace_state/union.rb', line 38 def state_convolution num_covered > 0 end |