···11package hashset
2233+import (
44+ "maps"
55+)
66+37type Set[T comparable] map[T]struct{}
4859// New creates and returns a new empty Set.
···2125func (s Set[T]) Size() int {
2226 return len(s)
2327}
2828+2929+// Union returns a new set containing all elements from s and other.
3030+func (s Set[T]) Union(other Set[T]) Set[T] {
3131+ result := make(Set[T], len(s)+len(other))
3232+ maps.Copy(result, s)
3333+ maps.Copy(result, other)
3434+ return result
3535+}