Class: Stupidedi::Sets::AbstractSet
- Inherits:
-
Object
- Object
- Stupidedi::Sets::AbstractSet
- Includes:
- Inspect
- Defined in:
- lib/stupidedi/sets/abstract_set.rb
Overview
AbstractSet describes the common interface implemented by its concrete subclasses. The two main implementations are RelativeSet and AbsoluteSet which are each optimized for different kinds of set operations.
Direct Known Subclasses
Set Operations (collapse)
-
- (AbstractSet) &(other)
Computes the intersection of two sets: the set of elements common between both sets.
-
- (AbstractSet) +(other)
Computes the union of two sets: the set of elements in either or both sets.
-
- (AbstractSet) -(other)
Computes the difference of two sets: the set of elements elements in this set and not the other.
-
- (AbstractSet) ^(other)
Computes the symmetric difference of two sets: the set of elements which are in either of the two sets but not in both.
-
- (AbstractSet) |(other)
Computes the union of two sets: the set of elements in either or both sets.
-
- (AbstractSet) ~
Computes the complement of the set: the set of elements not in this set.
Set Ordering (collapse)
-
- (Boolean) <(other)
True if this set is a subset of the
otherset and there exists at least one element in theotherset that doesn't belong to this set. -
- (Boolean) <=(other)
True if every element in this set also belongs to the
otherset. -
- (Boolean) >(other)
True if this set is a superset of the
otherset and there exists at least one element in this set that doesn't belong to theotherset. -
- (Boolean) >=(other)
True if every element in the
otherset also belongs to this set. -
- (Boolean) disjoint?(other)
True if this and the
otherset have no common elements. -
- (Boolean) proper_subset?(other)
True if this set is a subset of the
otherset and there exists at least one element in theotherset that doesn't belong to this set. -
- (Boolean) proper_superset?(other)
True if this set is a superset of the
otherset and there exists at least one element in this set that doesn't belong to theotherset. -
- (Boolean) subset?(other)
True if every element in this set also belongs to the
otherset. -
- (Boolean) superset?(other)
True if every element in the
otherset also belongs to this set.
Instance Method Summary (collapse)
-
- (Boolean) exclude?(object)
True if the set does not include the given
object. -
- (Boolean) infinite?
True if the set contains infinitely many elements.
-
- (AbstractSet) replace
Returns the
otherset, converting it to an AbstractSet if it isn't already. -
- (Numeric) size
Returns the number of elements in the set.
Methods included from Inspect
Instance Method Details
- (AbstractSet) &(other)
Computes the intersection of two sets: the set of elements common between both sets.
107 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 107 def &(other) intersection(other) end |
- (AbstractSet) +(other)
Computes the union of two sets: the set of elements in either or both sets
75 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 75 def +(other) union(other) end |
- (AbstractSet) -(other)
Computes the difference of two sets: the set of elements elements in this set and not the other.
83 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 83 def -(other) difference(other) end |
- (Boolean) <(other)
True if this set is a subset of the other set and there exists at
least one element in the other set that doesn't belong to this set
158 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 158 def <(other) proper_subset?(other) end |
- (Boolean) <=(other)
True if every element in this set also belongs to the other set
164 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 164 def <=(other) subset?(other) end |
- (Boolean) >(other)
True if this set is a superset of the other set and there exists at
least one element in this set that doesn't belong to the other set
161 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 161 def >(other) proper_superset?(other) end |
- (Boolean) >=(other)
True if every element in the other set also belongs to this set
167 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 167 def >=(other) superset?(other) end |
- (AbstractSet) ^(other)
Computes the symmetric difference of two sets: the set of elements which are in either of the two sets but not in both.
99 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 99 def ^(other) symmetric_difference(other) end |
- (Boolean) disjoint?(other)
True if this and the other set have no common elements
148 149 150 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 148 def disjoint?(other) intersection(other).empty? end |
- (Boolean) exclude?(object)
True if the set does not include the given object
17 18 19 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 17 def exclude?(object) not include?(object) end |
- (Boolean) infinite?
True if the set contains infinitely many elements
39 40 41 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 39 def infinite? not finite? end |
- (Boolean) proper_subset?(other)
True if this set is a subset of the other set and there exists at
least one element in the other set that doesn't belong to this set
126 127 128 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 126 def proper_subset?(other) other.size > size and subset?(other) end |
- (Boolean) proper_superset?(other)
True if this set is a superset of the other set and there exists at
least one element in this set that doesn't belong to the other set
141 142 143 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 141 def proper_superset?(other) other.size < size and superset?(other) end |
- (AbstractSet) replace
Returns the other set, converting it to an Stupidedi::Sets::AbstractSet if it isn't
already.
36 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 36 abstract :replace, :args => %w(other) |
- (Numeric) size
Returns the number of elements in the set
30 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 30 abstract :size |
- (Boolean) subset?(other)
True if every element in this set also belongs to the other set
118 119 120 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 118 def subset?(other) intersection(other) == self end |
- (Boolean) superset?(other)
True if every element in the other set also belongs to this set
133 134 135 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 133 def superset?(other) intersection(other) == other end |
- (AbstractSet) |(other)
Computes the union of two sets: the set of elements in either or both sets
72 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 72 def |(other) union(other) end |
- (AbstractSet) ~
Computes the complement of the set: the set of elements not in this set
91 |
# File 'lib/stupidedi/sets/abstract_set.rb', line 91 def ~; complement end |