provide a way to run app
This commit is contained in:
25
pkg/collections/set.go
Normal file
25
pkg/collections/set.go
Normal file
@ -0,0 +1,25 @@
|
||||
package collections
|
||||
|
||||
type Set[V comparable] map[V]struct{}
|
||||
|
||||
func NewSet[V comparable](values ...V) Set[V] {
|
||||
out := make(map[V]struct{}, len(values))
|
||||
for _, value := range values {
|
||||
out[value] = struct{}{}
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func (s Set[V]) Array() []V {
|
||||
out := make([]V, 0, len(s))
|
||||
for k := range s {
|
||||
out = append(out, k)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (s Set[V]) Contains(other V) bool {
|
||||
_, ok := s[other]
|
||||
return ok
|
||||
}
|
||||
Reference in New Issue
Block a user