File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -175,8 +175,8 @@ type Set[T comparable] interface {
175175 UnmarshalJSON (b []byte ) error
176176}
177177
178- // NewSet creates and returns a reference to an empty set. Operations
179- // on the resulting set are thread-safe.
178+ // NewSet creates and returns a new set with the given elements.
179+ // Operations on the resulting set are thread-safe.
180180func NewSet [T comparable ](vals ... T ) Set [T ] {
181181 s := newThreadSafeSet [T ]()
182182 for _ , item := range vals {
@@ -198,10 +198,13 @@ func NewSetFromSlice[T comparable](v []T) Set[T] {
198198 return s
199199}
200200
201- // NewThreadUnsafeSet creates and returns a reference to an empty set .
201+ // NewThreadUnsafeSet creates and returns a new set with the given elements .
202202// Operations on the resulting set are not thread-safe.
203- func NewThreadUnsafeSet [T comparable ]() Set [T ] {
203+ func NewThreadUnsafeSet [T comparable ](vals ... T ) Set [T ] {
204204 s := newThreadUnsafeSet [T ]()
205+ for _ , item := range vals {
206+ s .Add (item )
207+ }
205208 return & s
206209}
207210
You can’t perform that action at this time.
0 commit comments