Documentation ¶
Index ¶
- type OrderedSet
- func (s OrderedSet[T]) AsSet() Set[T]
- func (s OrderedSet[T]) AsSlice() []T
- func (s OrderedSet[T]) Clone() OrderedSet[T]
- func (s OrderedSet[T]) Contains(v T) bool
- func (s OrderedSet[T]) ContainsAll(vs ...T) bool
- func (s OrderedSet[T]) ContainsAny(vs ...T) bool
- func (s OrderedSet[T]) Delete(vs ...T)
- func (s OrderedSet[T]) Equals(other OrderedSet[T]) bool
- func (s OrderedSet[T]) Insert(vs ...T)
- func (s OrderedSet[T]) Intersect(other OrderedSet[T])
- func (s OrderedSet[T]) IsEmpty() bool
- func (s OrderedSet[T]) MarshalJSON() ([]byte, error)
- func (s OrderedSet[T]) Size() int
- func (s OrderedSet[T]) Union(other OrderedSet[T])
- func (s *OrderedSet[T]) UnmarshalJSON(text []byte) error
- type Set
- func (s Set[T]) AsSlice() []T
- func (s Set[T]) Clear()
- func (s Set[T]) Clone() Set[T]
- func (s Set[T]) Contains(v T) bool
- func (s Set[T]) ContainsAll(vs ...T) bool
- func (s Set[T]) ContainsAny(vs ...T) bool
- func (s Set[T]) Delete(vs ...T)
- func (s Set[T]) Equals(other Set[T]) bool
- func (s Set[T]) Get(v T) optionals.Optional[T]
- func (s Set[T]) Insert(vs ...T)
- func (s Set[T]) Intersect(other Set[T])
- func (s Set[T]) IsEmpty() bool
- func (s Set[T]) MarshalJSON() ([]byte, error)
- func (s Set[T]) Size() int
- func (s Set[T]) Union(other Set[T])
- func (s *Set[T]) UnmarshalJSON(text []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OrderedSet ¶
type OrderedSet[T constraints.Ordered] map[T]struct{}
func AsOrderedSet ¶
func AsOrderedSet[T constraints.Ordered](s Set[T]) OrderedSet[T]
Returns the set as an OrderedSet. Changes to the returned OrderedSet will be reflected in this set.
func IntersectOrdered ¶
func IntersectOrdered[T constraints.Ordered](sets ...OrderedSet[T]) OrderedSet[T]
Creates a new set from the intersection of sets.
func MapOrdered ¶
func MapOrdered[T, U constraints.Ordered](ts OrderedSet[T], f func(T) U) OrderedSet[U]
Applies the given function to each element of an ordered set. Returns the resulting set of function outputs.
func NewOrderedSet ¶
func NewOrderedSet[T constraints.Ordered](vs ...T) OrderedSet[T]
func (OrderedSet[T]) AsSet ¶
func (s OrderedSet[T]) AsSet() Set[T]
Returns the set as a Set. Changes to the returned Set will be reflected in this set.
func (OrderedSet[T]) AsSlice ¶
func (s OrderedSet[T]) AsSlice() []T
Returns the set as a sorted slice.
func (OrderedSet[T]) Clone ¶
func (s OrderedSet[T]) Clone() OrderedSet[T]
func (OrderedSet[T]) Contains ¶
func (s OrderedSet[T]) Contains(v T) bool
func (OrderedSet[T]) ContainsAll ¶
func (s OrderedSet[T]) ContainsAll(vs ...T) bool
func (OrderedSet[T]) ContainsAny ¶
func (s OrderedSet[T]) ContainsAny(vs ...T) bool
func (OrderedSet[T]) Delete ¶
func (s OrderedSet[T]) Delete(vs ...T)
func (OrderedSet[T]) Equals ¶
func (s OrderedSet[T]) Equals(other OrderedSet[T]) bool
func (OrderedSet[T]) Insert ¶
func (s OrderedSet[T]) Insert(vs ...T)
func (OrderedSet[T]) Intersect ¶
func (s OrderedSet[T]) Intersect(other OrderedSet[T])
func (OrderedSet[T]) IsEmpty ¶
func (s OrderedSet[T]) IsEmpty() bool
func (OrderedSet[T]) MarshalJSON ¶
func (s OrderedSet[T]) MarshalJSON() ([]byte, error)
Marshals as a sorted slice.
func (OrderedSet[T]) Size ¶
func (s OrderedSet[T]) Size() int
func (OrderedSet[T]) Union ¶
func (s OrderedSet[T]) Union(other OrderedSet[T])
func (*OrderedSet[T]) UnmarshalJSON ¶
func (s *OrderedSet[T]) UnmarshalJSON(text []byte) error
type Set ¶
type Set[T comparable] map[T]struct{}
func FilterMap ¶
func FilterMap[T, U comparable](ts Set[T], f func(T) optionals.Optional[U]) Set[U]
Applies the given function to each element of a set. Removes any None results and returns the rest.
func Intersect ¶
func Intersect[T comparable](sets ...Set[T]) Set[T]
Creates a new set from the intersection of sets.
func Map ¶
func Map[T, U comparable](ts Set[T], f func(T) U) Set[U]
Applies the given function to each element of a set. Returns the resulting set of function outputs.
func NewSet ¶
func NewSet[T comparable](vs ...T) Set[T]
func (Set[T]) AsSlice ¶
func (s Set[T]) AsSlice() []T
AsSlice returns the set as a slice in a nondeterministic order.
func (Set[T]) ContainsAll ¶
func (Set[T]) ContainsAny ¶
func (Set[T]) Get ¶
Converts v to an optional value, depending on whether it is a member of s. Returns Some(v) if s contains v. Returns None otherwise.