Class: Axiom::Algebra::Union
- Includes:
- Relation::Operation::Set
- Defined in:
- lib/axiom/algebra/union.rb
Overview
The union between relations
Defined Under Namespace
Modules: Methods
Instance Attribute Summary
Attributes included from Operation::Binary
Attributes inherited from Relation
Instance Method Summary collapse
-
#delete(other) ⇒ Union
Delete a relation from the Union.
-
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set.
-
#insert(other) ⇒ Union
Insert a relation into the Union.
Methods included from Relation::Operation::Set
Methods included from Relation::Operation::Binary
Methods included from Operation::Binary
Methods inherited from Relation
#==, #[], #directions, #empty?, #include?, #initialize, #materialize, #materialized?, new, #replace
Methods included from Visitable
Instance Method Details
#delete(other) ⇒ Union
Delete a relation from the Union
56 57 58 |
# File 'lib/axiom/algebra/union.rb', line 56 def delete(other) left.delete(other).union(right.delete(other)) end |
#each {|tuple| ... } ⇒ self
Iterate over each tuple in the set
24 25 26 27 28 29 30 |
# File 'lib/axiom/algebra/union.rb', line 24 def each return to_enum unless block_given? seen = {} left.each { |tuple| yield seen[tuple] = tuple } right.each { |tuple| yield tuple unless seen.key?(tuple) } self end |
#insert(other) ⇒ Union
Insert a relation into the Union
42 43 44 |
# File 'lib/axiom/algebra/union.rb', line 42 def insert(other) left.insert(other).union(right.insert(other)) end |