Documentation ¶
Index ¶
- func Equals[T comparable](s1 Set[T], s2 Set[T]) bool
- type Set
- func Convert[T comparable, R comparable](s Set[T], convert func(v T) R) Set[R]
- func Difference[T comparable](s1 Set[T], s2 Set[T]) Set[T]
- func Intersect[T comparable](s1 Set[T], s2 Set[T]) Set[T]
- func New[T comparable](values ...T) Set[T]
- func SymmetricDifference[T comparable](s1 Set[T], s2 Set[T]) Set[T]
- func Union[T comparable](s1 Set[T], s2 Set[T]) Set[T]
- func (s Set[T]) Add(value T)
- func (s Set[T]) AddAll(values ...T)
- func (s Set[T]) AddSet(set Set[T])
- func (s Set[T]) Contains(value T) bool
- func (s Set[T]) ContainsAny(values ...T) bool
- func (s Set[T]) Copy() Set[T]
- func (s Set[T]) ForEach(f func(value T))
- func (s Set[T]) Remove(value T)
- func (s Set[T]) RemoveAll(values ...T)
- func (s Set[T]) RemoveSet(set Set[T])
- func (s Set[T]) Select(predicate func(v T) bool) Set[T]
- func (s Set[T]) Size() int
- func (s Set[T]) ToSlice() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Set ¶
type Set[T comparable] map[T]empty
Set implements set using hash table
func Convert ¶
func Convert[T comparable, R comparable](s Set[T], convert func(v T) R) Set[R]
Convert return a new Set, contains values by applying convert func on original set
func Difference ¶
func Difference[T comparable](s1 Set[T], s2 Set[T]) Set[T]
Difference return difference set s2 from set s1 (s1-s2), which is a set of elements that are only in s1 but not in s2.
func Intersect ¶
func Intersect[T comparable](s1 Set[T], s2 Set[T]) Set[T]
Intersect return intersection of two sets.
func SymmetricDifference ¶
func SymmetricDifference[T comparable](s1 Set[T], s2 Set[T]) Set[T]
SymmetricDifference return symmetric difference two sets, which is a set of elements in s1 and s2 but not in both (excluding the intersection).
func (Set[T]) ContainsAny ¶
ContainsAny return if set contains anyone of the values
func (Set[T]) ForEach ¶
func (s Set[T]) ForEach(f func(value T))
ForEach traverse all element in this set
Click to show internal directories.
Click to hide internal directories.