sets

package
v0.0.0-...-b95d4ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

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]) Clear

func (s Set[T]) Clear()

func (Set[T]) Clone

func (s Set[T]) Clone() Set[T]

func (Set[T]) Contains

func (s Set[T]) Contains(v T) bool

func (Set[T]) ContainsAll

func (s Set[T]) ContainsAll(vs ...T) bool

func (Set[T]) ContainsAny

func (s Set[T]) ContainsAny(vs ...T) bool

func (Set[T]) Delete

func (s Set[T]) Delete(vs ...T)

func (Set[T]) Equals

func (s Set[T]) Equals(other Set[T]) bool

func (Set[T]) Get

func (s Set[T]) Get(v T) optionals.Optional[T]

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.

func (Set[T]) Insert

func (s Set[T]) Insert(vs ...T)

func (Set[T]) Intersect

func (s Set[T]) Intersect(other Set[T])

func (Set[T]) IsEmpty

func (s Set[T]) IsEmpty() bool

func (Set[T]) MarshalJSON

func (s Set[T]) MarshalJSON() ([]byte, error)

func (Set[T]) Size

func (s Set[T]) Size() int

func (Set[T]) Union

func (s Set[T]) Union(other Set[T])

func (*Set[T]) UnmarshalJSON

func (s *Set[T]) UnmarshalJSON(text []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL