Documentation ¶
Index ¶
- type Set
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Count() int
- func (s Set[T]) Has(value T) bool
- func (s Set[T]) Remove(value T)
- func (s Set[T]) RemoveIf(predicate func(T) bool) bool
- func (s Set[T]) RemoveTest(value T) bool
- func (s Set[T]) Set(value T)
- func (s Set[T]) SetTest(value T) bool
- func (s Set[T]) ToSlice() []T
- func (s Set[T]) ToString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[T comparable] map[T]struct{}
Set is a simple set using an underlying map
func With ¶
func With[T comparable](values ...T) Set[T]
With creates a simple set with the given values as the keys in the map.
func (Set[T]) Clone ¶
Clone creates a shallow clone of the set. This will not deep copying the values.
func (Set[T]) Remove ¶
func (s Set[T]) Remove(value T)
Remove removes the given value from the set. Has no effect if the value is not already set.
func (Set[T]) RemoveIf ¶
RemoveIf removes any value which the given predicate accepts. Returns true if any value was remove, otherwise false if none were removed.
func (Set[T]) RemoveTest ¶
RemoveTest removes the given value from the set if it exists. Returns true if the value was removed, otherwise false if not set.
func (Set[T]) Set ¶
func (s Set[T]) Set(value T)
Set the given value in the set. Has no effect if the value is already set.
func (Set[T]) SetTest ¶
SetTest checks if the value exists or not before being set. Returns true if value is new, otherwise false if already set.