feat(set): add NewFromSlice
function
This commit is contained in:
parent
f8c0f0eddb
commit
c228caa309
5
set.go
5
set.go
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user