Documentation
¶
Index ¶
- func MembersOfType[M any, T comparable](s Set[T]) iter.Seq[M]
- type Set
- func (s Set[T]) AsSlice() []T
- func (s *Set[T]) Clear()
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Empty() bool
- func (s Set[T]) Equal(o Set[T]) bool
- func (s Set[T]) Get() (m T, found bool)
- func (s Set[T]) Has(member T) bool
- func (s *Set[T]) Insert(member T) (changed bool)
- func (s Set[T]) Len() int
- func (s Set[T]) Members() iter.Seq[T]
- func (s *Set[T]) Merge(sets ...Set[T]) (changed bool)
- func (s *Set[T]) Remove(member T) (changed bool)
- func (s *Set[T]) RemoveSets(sets ...Set[T]) (changed bool)
- func (s Set[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MembersOfType ¶
func MembersOfType[M any, T comparable](s Set[T]) iter.Seq[M]
MembersOfType return an iterator for each member of type M in the set.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set contains zero, one, or more members. Zero or one members do not consume any additional storage, more than one members are held in an non-exported membersMap.
func NewSet ¶
func NewSet[T comparable](members ...T) Set[T]
NewSet returns a Set initialized to contain the members in 'members'.
func (Set[T]) Get ¶
Get returns any one member from the set. Useful when it is known that the set has only one element.
func (*Set[T]) Insert ¶
Insert inserts a member to the set. Returns 'true' when '*s' value has changed, so that if it is stored by value the caller must knows to update the stored value.
func (*Set[T]) Merge ¶
Merge inserts members in 'o' into to the set 's'. Returns 'true' when '*s' value has changed, so that if it is stored by value the caller must knows to update the stored value.
func (*Set[T]) Remove ¶
Remove removes a member from the set. Returns 'true' when '*s' value was changed, so that if it is stored by value the caller knows to update the stored value.
func (*Set[T]) RemoveSets ¶
RemoveSets removes one or more Sets from the receiver set. Returns 'true' when '*s' value was changed, so that if it is stored by value the caller knows to update the stored value.