Documentation
¶
Overview ¶
Provides a generic implementation of a set of elements.
Index ¶
- func Disjoint[Key comparable](a, b Set[Key], sets ...Set[Key]) bool
- func Equal[Key comparable](a, b Set[Key], sets ...Set[Key]) bool
- type Set
- func Difference[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
- func Intersection[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
- func New[Key comparable](keys ...Key) Set[Key]
- func SymmetricDifference[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
- func Union[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
- func (s Set[Key]) Add(key Key, keys ...Key)
- func (s Set[Key]) Contains(key Key, keys ...Key) bool
- func (s Set[Key]) Copy() Set[Key]
- func (s Set[Key]) Del(key Key, keys ...Key)
- func (s Set[Key]) Elements() []Key
- func (s Set[Key]) Intersect(a Set[Key], sets ...Set[Key])
- func (s Set[Key]) IsSubsetOf(other Set[Key]) (ok bool, proper bool)
- func (s Set[Key]) IsSupersetOf(other Set[Key]) (ok bool, proper bool)
- func (s Set[Key]) Remove(a Set[Key], sets ...Set[Key])
- func (s Set[Key]) SymmetricRemove(a Set[Key], sets ...Set[Key])
- func (s Set[Key]) Update(a Set[Key], sets ...Set[Key])
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Set ¶
type Set[Key comparable] map[Key]struct{}
Set is a generic set of elements (keys).
func Difference ¶
func Difference[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
Difference returns the difference of all the sets: a ∖ b ∖ sets[0] ∖ sets[1] ...
func Intersection ¶
func Intersection[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
Intersetion returns the intersection of all the sets: ⋂(a, b, sets) = a ∩ b ∩ sets[0] ∩ sets[1] ...
func New ¶
func New[Key comparable](keys ...Key) Set[Key]
New creates a new set that contains all the given keys.
func SymmetricDifference ¶
func SymmetricDifference[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
SymmetricDifference returns the difference between the union and intersection of all the sets: ⋃(a, b, sets) ∖ ⋂(a, b, sets).
func Union ¶
func Union[Key comparable](a, b Set[Key], sets ...Set[Key]) Set[Key]
Union returns the union of all the sets: ⋃(a, b, sets) = a ∪ b ∪ sets[0] ∪ sets[1] ...
func (Set[Key]) Elements ¶
func (s Set[Key]) Elements() []Key
Elements returns all the keys in the set as an unordered slice.
func (Set[Key]) IsSubsetOf ¶
IsSubsetOf returns a pair of values:
- ok=true if s is a subset of other
- proper=true if s is a proper subset (i.e., !Equal(s, other)))
func (Set[Key]) IsSupersetOf ¶
IsSupersetOf returns a pair of values:
- ok=true if s is a superset of other
- proper=true if s is a proper superset (i.e., !Equal(s, other)))
func (Set[Key]) SymmetricRemove ¶
SymmetricRemove is like SymmetricDifference, but modifies the set in place.