mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
feat: add NewSetFromSlice function for set
This commit is contained in:
1 parent
acb5844b15
commit
37c7508ad0
2 files changed
+22
No files matched your search
@@ -10,6 +10,15 @@ func NewSet[T comparable](items ...T) Set[T] {
|
||||
return set
|
||||
}
|
||||
|
||||
// NewSetFromSlice create a set from slice
|
||||
func NewSetFromSlice[T comparable](items []T) Set[T] {
|
||||
set := make(Set[T])
|
||||
for _, item := range items {
|
||||
set.Add(item)
|
||||
}
|
||||
return set
|
||||
}
|
||||
|
||||
// Add items to set
|
||||
func (s Set[T]) Add(items ...T) {
|
||||
for _, v := range items {
|
||||
|
||||
Reference in new issue
Block a user