diff --git a/tools/utils/set.go b/tools/utils/set.go index 477fa9646..cff09034c 100644 --- a/tools/utils/set.go +++ b/tools/utils/set.go @@ -84,7 +84,7 @@ func (self *Set[T]) Subtract(other *Set[T]) (ans *Set[T]) { return ans } -func (self *Set[T]) IsSubset(other *Set[T]) bool { +func (self *Set[T]) IsSubsetOf(other *Set[T]) bool { for x := range self.items { if !other.Has(x) { return false @@ -101,3 +101,9 @@ func NewSet[T comparable](capacity ...int) (ans *Set[T]) { } return } + +func NewSetWithItems[T comparable](items ...T) (ans *Set[T]) { + ans = NewSet[T](len(items)) + ans.AddItems(items...) + return ans +}