Documentation
¶
Index ¶
- func IsEmptySet[T comparable](s *Set[T]) bool
- type Set
- func (s *Set[T]) Add(x T) error
- func (s *Set[T]) Capacity() int
- func (s *Set[T]) Clear()
- func (s *Set[T]) Enumerate() []T
- func (s *Set[T]) Equal(s2 *Set[T]) bool
- func (s *Set[T]) Filter(p func(T) bool) *Set[T]
- func (s *Set[T]) Hash() string
- func (s *Set[T]) IsElementOf(x T) bool
- func (s *Set[T]) Iter() iter.Seq[T]
- func (s *Set[T]) Map(f func(T) T) *Set[T]
- func (s *Set[T]) Pick()
- func (s *Set[T]) Pop() (v T, ok bool)
- func (s *Set[T]) Remove(x T)
- func (s *Set[T]) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEmptySet ¶
func IsEmptySet[T comparable](s *Set[T]) bool
IsEmptySet checks whether the set S is empty.
Types ¶
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
https://en.wikipedia.org/wiki/Set_(abstract_data_type)#Operations
func BuildSet ¶
func BuildSet[T comparable](xn ...T) *Set[T]
BuildSet creates a set structure with values x1,x2,...,xn.
func Collect ¶
func Collect[T comparable](collection iter.Seq[T]) *Set[T]
Collect creates a new set structure containing all the elements of the given collection or all the elements returned by the given iterator.
func CreateSet ¶
func CreateSet[T comparable]() *Set[T]
CreateSet creates a new, initially empty set structure.
func CreateSetWithCapacity ¶
func CreateSetWithCapacity[T comparable](n int) *Set[T]
CreateSetWithCapacity creates a new set structure, initially empty but capable of holding up to n elements.
func (*Set[T]) Enumerate ¶
func (s *Set[T]) Enumerate() []T
Enumerate returns a list containing the elements of S in some arbitrary order.
func (*Set[T]) Equal ¶
Equal checks whether the two given sets are equal (i.e. contain all and only the same elements).
func (*Set[T]) Filter ¶
Filter returns the subset containing all elements of S that satisfy a given predicate P.
func (*Set[T]) Hash ¶
Hash returns a hash value for the static set S such that if equal(S1, S2) then hash(S1) = hash(S2)
func (*Set[T]) IsElementOf ¶
IsElementOf checks whether the value x is in the set S.
func (*Set[T]) Map ¶
Map returns the set of distinct values resulting from applying function F to each element of S.
func (*Set[T]) Pick ¶
func (s *Set[T]) Pick()
Pick returns an arbitrary element of S. Functionally, the mutator pop can be interpreted as the pair of selectors (pick, rest), where rest returns the set consisting of all elements except for the arbitrary element. Can be interpreted in terms of iterate.