Skip to content

Commit

Permalink
ex6.3: Fix InterceptWith and DifferenceWith
Browse files Browse the repository at this point in the history
  • Loading branch information
soon1995 committed Apr 19, 2023
1 parent fdd89d9 commit 914da8d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ex6.3/intset.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,18 @@ func (s *IntSet) IntersectWith(t *IntSet) {
for i, tword := range t.words {
if i < len(s.words) {
s.words[i] &= tword
} else {
s.words = append(s.words, tword)
}
}
for i := len(t.words); i < len(s.words); i++ {
s.words[i] = 0
}
}

// Set s to the difference of s and t.
func (s *IntSet) DifferenceWith(t *IntSet) {
for i, tword := range t.words {
if i < len(s.words) {
s.words[i] &^= tword
} else {
s.words = append(s.words, tword)
}
}
}
Expand Down

0 comments on commit 914da8d

Please sign in to comment.