set/set.go

28 lines
510 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)
InsertSlice([]T) (inserted []bool)
Contains(T) bool
ContainsSlice([]T) []bool
Remove(T) (removed bool)
RemoveSlice([]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]()
}
}