mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix comparison methods of Set to check if @hash
is actually comparable
This should fix comparison of rbtree backed SortedSet instances. [Bug #12072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dcea9198a9
commit
c1c527c290
1 changed files with 4 additions and 4 deletions
|
@ -237,7 +237,7 @@ class Set
|
|||
# Returns true if the set is a superset of the given set.
|
||||
def superset?(set)
|
||||
case
|
||||
when set.instance_of?(self.class)
|
||||
when set.instance_of?(self.class) && @hash.respond_to?(:>=)
|
||||
@hash >= set.instance_variable_get(:@hash)
|
||||
when set.is_a?(Set)
|
||||
size >= set.size && set.all? { |o| include?(o) }
|
||||
|
@ -250,7 +250,7 @@ class Set
|
|||
# Returns true if the set is a proper superset of the given set.
|
||||
def proper_superset?(set)
|
||||
case
|
||||
when set.instance_of?(self.class)
|
||||
when set.instance_of?(self.class) && @hash.respond_to?(:>)
|
||||
@hash > set.instance_variable_get(:@hash)
|
||||
when set.is_a?(Set)
|
||||
size > set.size && set.all? { |o| include?(o) }
|
||||
|
@ -263,7 +263,7 @@ class Set
|
|||
# Returns true if the set is a subset of the given set.
|
||||
def subset?(set)
|
||||
case
|
||||
when set.instance_of?(self.class)
|
||||
when set.instance_of?(self.class) && @hash.respond_to?(:<=)
|
||||
@hash <= set.instance_variable_get(:@hash)
|
||||
when set.is_a?(Set)
|
||||
size <= set.size && all? { |o| set.include?(o) }
|
||||
|
@ -276,7 +276,7 @@ class Set
|
|||
# Returns true if the set is a proper subset of the given set.
|
||||
def proper_subset?(set)
|
||||
case
|
||||
when set.instance_of?(self.class)
|
||||
when set.instance_of?(self.class) && @hash.respond_to?(:<)
|
||||
@hash < set.instance_variable_get(:@hash)
|
||||
when set.is_a?(Set)
|
||||
size < set.size && all? { |o| set.include?(o) }
|
||||
|
|
Loading…
Add table
Reference in a new issue