feat(set): add NewFromSlice function
All checks were successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
Piotr Icikowski 2024-05-28 00:50:19 +02:00
parent f8c0f0eddb
commit c228caa309
Signed by: Piotr Icikowski
GPG Key ID: 3931CA47A91F7666

5
set.go
View File

@ -22,6 +22,11 @@ func New[T comparable](data ...T) *Set[T] {
return set
}
// NewFromSlice creates a new set from a slice.
func NewFromSlice[T comparable](data []T) *Set[T] {
return New[T](data...)
}
// Size returns number of elements in set.
func (s *Set[T]) Size() int {
s.mux.RLock()