set/set.go

24 lines
431 B
Go
Raw Normal View History

2025-11-28 13:02:56 -05:00
package set
import (
"code.wmdillon.com/wmdillon/set/simpleset"
"code.wmdillon.com/wmdillon/set/threadsafeset"
2025-11-28 13:02:56 -05:00
)
type Set[T comparable] interface {
Add(element T)
Remove(element T)
Contains(element T) bool
Size() int
ToSlice() []T
2025-11-28 13:02:56 -05:00
}
func New[T comparable](threadsafe bool, elements ...T) Set[T] {
switch threadsafe {
case true:
return threadsafeset.New(elements...)
default:
return simpleset.New(elements...)
2025-11-28 13:02:56 -05:00
}
}