2025-11-28 13:02:56 -05:00
|
|
|
package set
|
|
|
|
|
|
|
|
|
|
import (
|
2026-07-24 23:29:07 -04:00
|
|
|
"code.wmdillon.com/wmdillon/set/simpleset"
|
|
|
|
|
"code.wmdillon.com/wmdillon/set/threadsafeset"
|
2025-11-28 13:02:56 -05:00
|
|
|
)
|
|
|
|
|
|
2026-07-24 23:29:07 -04: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
|
|
|
}
|
|
|
|
|
|
2026-07-24 23:29:07 -04: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
|
|
|
}
|
|
|
|
|
}
|