set/set.go

25 lines
412 B
Go
Raw Normal View History

2025-05-06 22:58:18 -04:00
package set
import (
2025-05-07 12:43:11 -04:00
"code.wmdillon.com/GoApi/set/simpleset"
"code.wmdillon.com/GoApi/set/threadsafeset"
2025-05-06 22:58:18 -04:00
)
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]()
}
}