24 lines
431 B
Go
24 lines
431 B
Go
package set
|
|
|
|
import (
|
|
"code.wmdillon.com/wmdillon/set/simpleset"
|
|
"code.wmdillon.com/wmdillon/set/threadsafeset"
|
|
)
|
|
|
|
type Set[T comparable] interface {
|
|
Add(element T)
|
|
Remove(element T)
|
|
Contains(element T) bool
|
|
Size() int
|
|
ToSlice() []T
|
|
}
|
|
|
|
func New[T comparable](threadsafe bool, elements ...T) Set[T] {
|
|
switch threadsafe {
|
|
case true:
|
|
return threadsafeset.New(elements...)
|
|
default:
|
|
return simpleset.New(elements...)
|
|
}
|
|
}
|