Nicer Set constructor
This commit is contained in:
parent
1df3ef648c
commit
43bcb41a2a
@ -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
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user