Documentation
¶
Index ¶
- func NewBasicMap[E comparable](sizeHint int) container.Set[E]
- type BasicMap
- func (s *BasicMap[E]) Add(item E) (found bool)
- func (s *BasicMap[E]) Clear() (count int)
- func (s *BasicMap[E]) Contains(item E) bool
- func (s *BasicMap[E]) Difference(other container.Set[E]) container.Set[E]
- func (s *BasicMap[E]) Intersection(other container.Set[E]) container.Set[E]
- func (s *BasicMap[E]) Items() iter.Seq[E]
- func (s *BasicMap[E]) Len() int
- func (s *BasicMap[E]) Remove(item E) (found bool)
- func (s *BasicMap[E]) String() string
- func (s *BasicMap[E]) Union(other container.Set[E]) container.Set[E]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBasicMap ¶
func NewBasicMap[E comparable](sizeHint int) container.Set[E]
NewBasicMap returns a ready-for-use container.Set implemented by the BasicMap type.
Types ¶
type BasicMap ¶
type BasicMap[E comparable] struct { // contains filtered or unexported fields }
BasicMap is the textbook Go implementation of a Go set using generics.
It is not concurrency-safe. For performance optimization, its union/intersection/difference operations may return the receiver or the argument instead of cloning.
func (*BasicMap[E]) Add ¶
Add adds an item to the set. Returns true if the item was already present.
func (*BasicMap[E]) Clear ¶
Clear removes all items from the set and returns the number of items removed.
func (*BasicMap[E]) Difference ¶
Difference returns a new set containing elements present in this set but not in the other.
func (*BasicMap[E]) Intersection ¶
Intersection returns a new set containing elements present in both sets.
func (*BasicMap[E]) Remove ¶
Remove removes an item from the set. It does not fail if the item was not present, and returns true if it was.