goc2p
goc2p copied to clipboard
Incorrect definition of `IsSuperset` !
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
}