mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-10 14:14:48 +02:00
Nicer Set constructor
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user