25 lines
412 B
Go
25 lines
412 B
Go
package set
|
|
|
|
import (
|
|
"code.wmdillon.com/GoApi/set/simpleset"
|
|
"code.wmdillon.com/GoApi/set/threadsafeset"
|
|
)
|
|
|
|
type Set[T comparable] interface {
|
|
Insert(T) (inserted bool)
|
|
Contains(T) bool
|
|
Remove(T) (removed bool)
|
|
Len() int
|
|
ToSlice() []T
|
|
Clear()
|
|
}
|
|
|
|
func New[T comparable](threadsafe bool) Set[T] {
|
|
switch threadsafe {
|
|
case true:
|
|
return threadsafeset.New[T]()
|
|
default:
|
|
return simpleset.New[T]()
|
|
}
|
|
}
|