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]) Iterate() (xcontainer.IterateHandler[T], xcontainer.CancelHandler)
- 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 ¶
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]
creates a set structure with values x1,x2,...,xn.
func CreateFrom ¶
func CreateFrom[T comparable](collection xcontainer.Iterator[T]) *Set[T]
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]
creates a new, initially empty set structure.
func CreateSetWithCapacity ¶
func CreateSetWithCapacity[T comparable](n int) *Set[T]
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
returns a list containing the elements of S in some arbitrary order.
func (*Set[T]) Equal ¶
checks whether the two given sets are equal (i.e. contain all and only the same elements).
func (*Set[T]) Filter ¶
returns the subset containing all elements of S that satisfy a given predicate P.
func (*Set[T]) 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 ¶
checks whether the value x is in the set S.
func (*Set[T]) Iterate ¶
func (s *Set[T]) Iterate() (xcontainer.IterateHandler[T], xcontainer.CancelHandler)
returns a function that returns one more value of S at each call, in some arbitrary order.
func (*Set[T]) 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()
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.