mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
feat: add Minus func for set
This commit is contained in:
1 parent
79867e8a63
commit
f28b5b2f92
2 files changed
+24
No files matched your search
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user