Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect definition of IsSuperset ! #8

Open
minghu6 opened this issue Dec 29, 2016 · 0 comments
Open

Incorrect definition of IsSuperset ! #8

minghu6 opened this issue Dec 29, 2016 · 0 comments

Comments

@minghu6
Copy link

minghu6 commented Dec 29, 2016

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
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant