Documentation
¶
Overview ¶
Package set provides simple structure with iterator
Index ¶
- type Set
- func (s *Set[ST]) Clone() *Set[ST]
- func (s *Set[ST]) Contains(element ST) bool
- func (s *Set[ST]) Difference(other *Set[ST]) *Set[ST]
- func (s *Set[ST]) Equal(other *Set[ST]) bool
- func (s *Set[ST]) Insert(elements ...ST)
- func (s *Set[ST]) Intersection(set *Set[ST]) *Set[ST]
- func (s *Set[ST]) Len() int
- func (s *Set[ST]) ProperSubsetOf(other *Set[ST]) bool
- func (s *Set[ST]) Remove(elements ...ST)
- func (s *Set[T]) Seq() iter.Seq[T]
- func (s *Set[ST]) SubsetOf(other *Set[ST]) bool
- func (s *Set[ST]) SymmetricDifference(other *Set[ST]) (*Set[ST], *Set[ST])
- func (s *Set[ST]) Union(set *Set[ST]) *Set[ST]
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[ST comparable] struct { // contains filtered or unexported fields }
func New ¶
func New[T comparable](initial ...T) *Set[T]
func (*Set[ST]) Difference ¶
Difference returns unique elements for that set.
func (*Set[ST]) Insert ¶
func (s *Set[ST]) Insert(elements ...ST)
Insert adds an element to the set.
func (*Set[ST]) Intersection ¶
Intersection returns elements which are in both sets.
func (*Set[ST]) ProperSubsetOf ¶
ProperSubsetOf checks is this set a proper subset of "other".
func (*Set[ST]) Remove ¶
func (s *Set[ST]) Remove(elements ...ST)
Remove removes all element from the set. Missing elements do nothing.
func (*Set[T]) Seq ¶
Seq returns value-iterator.
Example ¶
s := New(1, 2, 3, 4)
for v := range s.Seq() {
fmt.Println(v)
}
Output: 1 2 3 4
func (*Set[ST]) SymmetricDifference ¶
SymmetricDifference returns unique elements for both sets.
Click to show internal directories.
Click to hide internal directories.