mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-11 08:12:26 +08:00
feat: add Minus func for set
This commit is contained in:
@@ -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