Documentation
¶
Index ¶
- type Set
- func (s *Set[K]) Add(element K) bool
- func (s *Set[K]) Clear()
- func (s *Set[K]) Contains(element K) bool
- func (s *Set[K]) Empty() bool
- func (s *Set[K]) Equals(set set.Seter[K]) bool
- func (s *Set[K]) ForEach(do func(*K))
- func (s *Set[K]) GetIntersection(set set.Seter[K]) set.Seter[K]
- func (s *Set[K]) GetUnion(set set.Seter[K]) set.Seter[K]
- func (s *Set[K]) Intersects(set set.Seter[K]) bool
- func (s *Set[K]) IsSubsetOf(set set.Seter[K]) bool
- func (s *Set[K]) IsSupersetOf(set set.Seter[K]) bool
- func (s *Set[K]) Remove(element K) bool
- func (s *Set[K]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set[K comparable] struct { // contains filtered or unexported fields }
A hash set that uses native go map under the hood. It implements Seter and Collectioner. Set is not thread safe
func New ¶
func New[K comparable](elements ...K) Set[K]
Creates an instance of Set with given elements and returns pointer to the instance. If no elements are given, an empty set is created. Elements must be comparable
func NewFromCollection ¶
func NewFromCollection[K comparable](c generic.Collectioner[K]) Set[K]
Creates an instance of Set with given collection and returns pointer to the instance. Elements must be comparable
func (*Set[K]) Add ¶
Adds the given element to the Set. If the element does not exist in the Set, Add will add the given element and return true. If the element already exists in the Set, Add will not add the given element and return false. Implements Seter.Add and Collectioner.Add
func (*Set[K]) Clear ¶
func (s *Set[K]) Clear()
Clears the current Set so it becomes empty. Under the hood, a new instance of builtin map is assigned as the new internal container Implements Seter.Clear
func (*Set[K]) Contains ¶
Returns true when the given element exists in the Set. Implements Seter.Contains and Collectioner.Contains
func (*Set[K]) Empty ¶
Returns true if the Set is empty. Implements Seter.Empty and Collectioner.Empty
func (*Set[K]) Equals ¶
Returns true when the given Set has the equal members as the current Set Implements Seter.Equals
func (*Set[K]) ForEach ¶
func (s *Set[K]) ForEach(do func(*K))
Iterates through each element in the Set and executes the given "do" function on each element. Implements Seter.ForEach and Collectioner.ForEach
func (*Set[K]) GetIntersection ¶
Returns a new instance of Set with the common members between the current Set and the given Set. Implements Seter.GetIntersection
func (*Set[K]) GetUnion ¶
Returns a new instance of Set with all the members of both the current Set and the given Set. Implements Seter.GetUnion
func (*Set[K]) Intersects ¶
Returns true when the given Set has common members with the current Set. Implements Seter.Intersects
func (*Set[K]) IsSubsetOf ¶
Returns true if the given Set has all the members of the current Set. Implements Seter.IsSubsetOf
func (*Set[K]) IsSupersetOf ¶
Returns true if the current Set contains all the members of the given Set. Implements Seter.IsSupersetOf