-
Notifications
You must be signed in to change notification settings - Fork 315
Incorrect definition of IsSuperset ! #8
Copy link
Copy link
Open
Description
code in basic/set
// 判断集合 one 是否是集合 other 的超集
func IsSuperset(one Set, other Set) bool {
if one == nil || other == nil {
return false
}
oneLen := one.Len()
otherLen := other.Len()
if oneLen == 0 || oneLen == otherLen {
return false
}
if oneLen > 0 && otherLen == 0 {
return true
}
for _, v := range other.Elements() {
if !one.Contains(v) {
return false
}
}
return true
}Proper super set is not equivalent of super set.
In other words, if one == other, then one issuperset of other(just like Python set.issuperset method).
if oneLen == 0 || oneLen == otherLen {
return false
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels