Documentation
¶
Index ¶
- type Set
- func (s Set[K]) Clone() Set[K]
- func (s Set[K]) ConstDifference(with ...K) Set[K]
- func (s Set[K]) ConstIntersection(with ...K) Set[K]
- func (s Set[K]) ConstSymmetricDifference(with ...K) Set[K]
- func (s Set[K]) ConstUnion(with ...K) Set[K]
- func (s Set[K]) Difference(others ...SetOf[K]) Set[K]
- func (s Set[K]) Equal(to SetOf[K]) bool
- func (s Set[K]) InPlaceDifference(others ...SetOf[K]) Set[K]
- func (s Set[K]) InPlaceIntersection(others ...SetOf[K]) Set[K]
- func (s Set[K]) InPlaceUnion(others ...SetOf[K]) Set[K]
- func (s Set[K]) Intersection(others ...SetOf[K]) Set[K]
- func (s Set[K]) IsDisjoint(other SetOf[K]) bool
- func (s Set[K]) IsProperSubset(to SetOf[K]) bool
- func (s Set[K]) IsProperSuperset(to SetOf[K]) bool
- func (s Set[K]) IsSubset(of SetOf[K]) bool
- func (s Set[K]) IsSuperset(of SetOf[K]) bool
- func (s Set[K]) Keys() []K
- func (s Set[K]) Map() map[K]struct{}
- func (s Set[K]) String() string
- func (s Set[K]) SymmetricDifference(others ...SetOf[K]) Set[K]
- func (s Set[K]) Union(others ...SetOf[K]) Set[K]
- type SetOf
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[K comparable] struct { SetOf[K] // contains filtered or unexported fields }
func NewHashset ¶
func NewMapset ¶
func NewMapset[K comparable](in ...K) Set[K]
func NewSet ¶
func NewSet[K comparable, S func() SetOf[K]](con S, in ...K) Set[K]
func (Set[K]) ConstDifference ¶
Example ¶
fmt.Print(NewMapset(1.2, 1.8, 2.6, 3.5).ConstDifference(1.2, 2.6))
Output: [1.8 3.5]
func (Set[K]) ConstIntersection ¶
Example ¶
fmt.Print(NewMapset("a", "b", "c").ConstIntersection("b", "c", "e"))
Output: [b c]
func (Set[K]) ConstSymmetricDifference ¶
Example ¶
fmt.Print(NewMapset(1, 2, 3).ConstSymmetricDifference(2, 3, 4))
Output: [1 4]
func (Set[K]) ConstUnion ¶
Example ¶
fmt.Print(NewMapset(1, 4, 7).ConstUnion(2, 3, 5, 6))
Output: [1 2 3 4 5 6 7]
func (Set[K]) Difference ¶
Example ¶
s := NewHashset(1, generic.Equals[int], generic.HashInt, 3, 4, 5, 6, 7)
o := NewMapset(5)
diff := s.Difference(o)
fmt.Println(diff)
fmt.Printf("%T", diff.SetOf) // the same type as the receiver
Output: [3 4 6 7] *hashset.Set[int]
func (Set[K]) InPlaceDifference ¶
func (Set[K]) InPlaceIntersection ¶
Example ¶
one := NewMapset(2, 3, 4) two := NewMapset(4, 5, 6) one.InPlaceIntersection(two) fmt.Print(one)
Output: [4]
func (Set[K]) InPlaceUnion ¶
func (Set[K]) Intersection ¶
Example ¶
s := NewMapset(1, 4, 7)
o := NewHashset(1, generic.Equals[int], generic.HashInt, 1, 7)
inter := s.Intersection(o)
fmt.Println(inter)
fmt.Printf("%T", inter.SetOf) // the same type as the receiver
Output: [1 7] mapset.Set[int]
func (Set[K]) IsDisjoint ¶
func (Set[K]) IsProperSubset ¶
func (Set[K]) IsProperSuperset ¶
func (Set[K]) IsSuperset ¶
func (Set[K]) Keys ¶
func (s Set[K]) Keys() []K
Example ¶
keys := NewMapset("one", "two").Keys()
sort.Strings(keys)
fmt.Println(keys)
Output: [one two]
func (Set[K]) SymmetricDifference ¶
Example ¶
one := NewMapset(2, 3, 4) two := NewMapset(4, 5, 6) fmt.Print(NewMapset(1, 2, 3).SymmetricDifference(one, two))
Output: [1 5 6]
type SetOf ¶
type SetOf[K comparable] interface { Put(val K) Has(val K) bool Remove(val K) Clear() Size() int Each(fn func(key K)) }
Click to show internal directories.
Click to hide internal directories.