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

Ex6.3 IntersectWith and DifferenceWith #23

Open
songjiyang opened this issue Dec 28, 2019 · 2 comments
Open

Ex6.3 IntersectWith and DifferenceWith #23

songjiyang opened this issue Dec 28, 2019 · 2 comments

Comments

@songjiyang
Copy link

IntersectWith and DifferenceWith is wrong, you should not append tword where i > len(s.words), test code below

var m, n IntSet
m.AddAll(1,3,5)
n.AddAll(1,2,5, 100, 1000)
fmt.Println("m:", &m)
fmt.Println("n:", &n)
//m.IntersectWith(&n)
//fmt.Println("After m.IntersectWith(&n) m:", &m)
m.DifferenceWith(&n)
fmt.Println("After m.DifferenceWith(&n) m:", &m)

//m: {1 3 5}
//n: {1 2 5 100 1000}
//After m.DifferenceWith(&n) m: {3 100 1000}
//m: {1 3 5}
//n: {1 2 5 100 1000}
//After m.IntersectWith(&n) m: {1 5 100 1000}
@zeliangchu
Copy link

agree

@soon1995
Copy link

soon1995 commented Apr 19, 2023

Not only this, we shall clear s[i] data where i >= len(t.words)

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

3 participants