Create a new set from a slice
(items []T)
| 15 | |
| 16 | // Create a new set from a slice |
| 17 | func NewFromSlice[T comparable](items []T) *Set[T] { |
| 18 | s := New[T]() |
| 19 | for _, item := range items { |
| 20 | s.Add(item) |
| 21 | } |
| 22 | return s |
| 23 | } |
| 24 | |
| 25 | // Checks if an element exists in the set |
| 26 | func (s *Set[T]) Has(item T) bool { |