feat: add Minus func for set

This commit is contained in:
dudaodong committed 2022-04-01 16:44:25 +08:00
1 parent 79867e8a63
commit f28b5b2f92
2 files changed
+24

No files matched your search

+13
View File
@@ -103,3 +103,16 @@ func (s Set[T]) Intersection(other Set[T]) Set[T] {
return set
}
// Minus creates an set of whose element in origin set but not in compared set
func (s Set[T]) Minus(comparedSet Set[T]) Set[T] {
set := NewSet[T]()
s.Iterate(func(value T) {
if !comparedSet.Contain(value) {
set.Add(value)
}
})
return set
}