Skip to content

Commit

Permalink
replace #intersect? with legacy style code
Browse files Browse the repository at this point in the history
  • Loading branch information
xronos-i-am committed Mar 13, 2023
1 parent 192fb33 commit a35a8b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/enum_machine_contrib/decision_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def resolve_strong_component!(component_cycled_vertex)
output_values = component_cycled_vertex.outcoming_edges.filter(&:active?).flat_map { |vertex| vertex.to.value }

active_vertexes = vertexes.filter(&:active?)
input_vertexes = active_vertexes.filter { |vertex| input_values.intersect?(vertex.value) }
output_vertexes = active_vertexes.filter { |vertex| output_values.intersect?(vertex.value) }
input_vertexes = active_vertexes.filter { |vertex| (input_values & vertex.value).any? }
output_vertexes = active_vertexes.filter { |vertex| (output_values & vertex.value).any? }

component_vertexes = active_vertexes.filter { |vertex| component_cycled_vertex.value.intersect?(vertex.value) }
component_vertexes = active_vertexes.filter { |vertex| (component_cycled_vertex.value & vertex.value).any? }

single_incoming_vertexes = (component_vertexes + output_vertexes).filter { |vertex| vertex.incoming_edges.size == 1 }
single_incoming_vertexes.each do |to_vertex|
Expand Down
6 changes: 3 additions & 3 deletions lib/enum_machine_contrib/decision_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def resolved

def as_dot
combined_values = values.filter(&:combined?).flat_map(&:value).to_set
visible_vertexes = values.reject { |vertex| combined_values.intersect?(vertex.value) && !vertex.combined? }
visible_vertexes = values.reject { |vertex| (combined_values & vertex.value).any? && !vertex.combined? }

cycled_vertexes, plain_vertexes = visible_vertexes.partition(&:cycled?)

Expand Down Expand Up @@ -123,8 +123,8 @@ def as_dot
transitions =
visible_vertexes.flat_map do |vertex|
vertex.outcoming_edges.filter_map do |edge|
if (!edge.from.combined? && combined_values.intersect?(edge.from.value)) ||
(!edge.to.combined? && combined_values.intersect?(edge.to.value))
if (!edge.from.combined? && (combined_values & edge.from.value).any?) ||
(!edge.to.combined? && (combined_values & edge.to.value).any?)
next
end

Expand Down

0 comments on commit a35a8b9

Please sign in to comment.