Class: IntervalNotation::SweepLine::TraceState::Tagging
- Inherits:
-
Struct
- Object
- Struct
- IntervalNotation::SweepLine::TraceState::Tagging
- Defined in:
- lib/interval_notation/sweep_line/trace_state/tagging.rb
Overview
Tagging is an abstract state class which stores an overlay markup of several tagged interval-sets. Look at SingleTagging and MultiTagging which implement different convolution strategies (see below).
Each interval set can be marked with the only tag but for an overlay each individual point can be marked with zero to many tags. Tag name is taken from boundary point’s interval index. Tag names needn’t be unique.
When a point is overlapped by several tags with the same name, there are two strategies:
-
SingleTagging takes into account only the fact, that the point/interval was tagged
-
MultiTagging count the number of times each tag was assigned to a point/interval
Direct Known Subclasses
Instance Attribute Summary collapse
-
#tag_count ⇒ Object
Returns the value of attribute tag_count.
Class Method Summary collapse
Instance Method Summary collapse
-
#state_after_point(points_on_place) ⇒ Object
map state before point (not at point!) into state after point.
-
#state_at_point(points_on_place) ⇒ Object
map state before point into state at point.
-
#state_convolution ⇒ Object
Convolve state inner state into state result.
Instance Attribute Details
#tag_count ⇒ Object
Returns the value of attribute tag_count
19 20 21 |
# File 'lib/interval_notation/sweep_line/trace_state/tagging.rb', line 19 def tag_count @tag_count end |
Class Method Details
.initial_state ⇒ Object
20 21 22 |
# File 'lib/interval_notation/sweep_line/trace_state/tagging.rb', line 20 def self.initial_state self.new(Hash.new(0)) end |
Instance Method Details
#state_after_point(points_on_place) ⇒ Object
map state before point (not at point!) into state after point
43 44 45 46 47 48 49 50 |
# File 'lib/interval_notation/sweep_line/trace_state/tagging.rb', line 43 def state_after_point(points_on_place) new_state = tag_count.dup points_on_place.reject(&:singular_point?).each{|point| new_state[point.interval_index] += point.opening ? 1 : -1 } new_state.reject!{|tag, count| count.zero?} self.class.new(new_state) end |
#state_at_point(points_on_place) ⇒ Object
map state before point into state at point
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/interval_notation/sweep_line/trace_state/tagging.rb', line 25 def state_at_point(points_on_place) new_state = tag_count.dup points_on_place.each{|point| if point.singular_point? new_state[point.interval_index] += 1 else if point.closing && !point.included new_state[point.interval_index] -= 1 elsif point.opening && point.included new_state[point.interval_index] += 1 end end } new_state.reject!{|tag, count| count.zero?} self.class.new(new_state) end |
#state_convolution ⇒ Object
Convolve state inner state into state result
53 54 55 |
# File 'lib/interval_notation/sweep_line/trace_state/tagging.rb', line 53 def state_convolution raise NotImplementedError, 'Tagging is an abstract state class. Use SingleTagging or MultiTagging instead' end |