Documentation ¶
Overview ¶
Package set is a template Set type
Tries to be similar to Python's set type
Index ¶
- type A
- type Set
- func (s *Set) Add(elem A) *Set
- func (s *Set) AddList(elems []A) *Set
- func (s *Set) AsList() []A
- func (s *Set) Clear() *Set
- func (s *Set) Contains(elem A) bool
- func (s *Set) Copy() *Set
- func (s *Set) Difference(other *Set) *Set
- func (s *Set) DifferenceUpdate(other *Set) *Set
- func (s *Set) Discard(elem A) *Set
- func (s *Set) Intersection(other *Set) *Set
- func (s *Set) IntersectionUpdate(other *Set) *Set
- func (s *Set) IsDisjoint(other *Set) bool
- func (s *Set) IsSubset(strict bool, other *Set) bool
- func (s *Set) IsSuperset(strict bool, other *Set) bool
- func (s *Set) Len() int
- func (s *Set) Pop(elem A) (A, bool)
- func (s *Set) Remove(elem A) bool
- func (s *Set) SymmetricDifference(other *Set) *Set
- func (s *Set) SymmetricDifferenceUpdate(other *Set) *Set
- func (s *Set) Union(other *Set) *Set
- func (s *Set) Update(other *Set) *Set
- type SetNothing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set provides a general purpose set modeled on Python's set type.
func NewSizedSet ¶
NewSizedSet returns a new empty set with the given capacity
func (*Set) Add ¶
Add adds elem to the set, returning the set
If the element already exists then it has no effect
func (*Set) AddList ¶
AddList adds a list of elems to the set
If the elements already exists then it has no effect
func (*Set) Difference ¶
Difference returns a new set with all the elements that are in this set but not in the other
func (*Set) DifferenceUpdate ¶
DifferenceUpdate removes all the elements that are in the other set from this set. It returns the set.
func (*Set) Discard ¶
Discard removes elem from the set
If it wasn't in the set it does nothing
It returns the set
func (*Set) Intersection ¶
Intersection returns a new set with all the elements that are only in this set and the other set. It returns the new set.
func (*Set) IntersectionUpdate ¶
IntersectionUpdate changes this set so that it only contains elements that are in both this set and the other set. It returns the set.
func (*Set) IsDisjoint ¶
IsDisjoint returns a bool indicating whether this set and other set have no elements in common.
func (*Set) IsSubset ¶
IsSubset returns a bool indicating whether this set is a subset of other set.
func (*Set) IsSuperset ¶
IsSuperset returns a bool indicating whether this set is a superset of other set.
func (*Set) Pop ¶
Pop removes elem from the set and returns it
It also returns whether the elem was found or not
func (*Set) Remove ¶
Remove removes elem from the set
It returns whether the elem was in the set or not
func (*Set) SymmetricDifference ¶
SymmetricDifference returns a new set of all elements that are a member of exactly one of this set and other set(elements which are in one of the sets, but not in both).
func (*Set) SymmetricDifferenceUpdate ¶
SymmetricDifferenceUpdate modifies this set to be a set of all elements that are a member of exactly one of this set and other set(elements which are in one of the sets, but not in both) and returns this set.