Documentation
¶
Index ¶
- func AreEqual[SetA, SetB CountableSetOf[T], T any](setA SetA, setB SetB) bool
- func CardinalityOf[T any](s CountableSetOf[T]) int
- func ContainsAllOf[T any](s SetOf[T], vs ...T) bool
- func ContainsAnyOf[T any](s SetOf[T], vs ...T) bool
- func QuickCardinalityOf[T any](s CountableSetOf[T]) (int, bool)
- type CountableSetOf
- func CountableIntersectionOf[SetA, SetB CountableSetOf[Item], Item any](setA SetA, setB SetB) CountableSetOf[Item]
- func CountableRelativeComplementOf[SetA, SetB CountableSetOf[Item], Item any](setA SetA, setB SetB) CountableSetOf[Item]
- func CountableUnionOf[SetA, SetB CountableSetOf[Item], Item any](setA SetA, setB SetB) CountableSetOf[Item]
- type Func
- type HashSet
- type KeyedSet
- func KeyedSetFromSeq[K comparable, V any](seq seqs.Seq[V], keyFn func(V) K) KeyedSet[K, V]
- func KeyedSetFromSlice[K comparable, V any](vs []V, keyFn func(V) K) KeyedSet[K, V]
- func KeyedSetFromValues[K comparable, V any](keyFn func(V) K, vs ...V) (res KeyedSet[K, V])
- func NewKeyedSet[K comparable, V any](keyFn func(V) K) KeyedSet[K, V]
- func (s KeyedSet[K, V]) Cardinality() int
- func (s KeyedSet[K, V]) Clone() KeyedSet[K, V]
- func (s KeyedSet[K, V]) Contains(v V) bool
- func (s *KeyedSet[K, V]) Exclude(vs ...V)
- func (s *KeyedSet[K, V]) ExcludeSeq(seq seqs.Seq[V])
- func (s KeyedSet[K, V]) ForEachUntil(fn func(V) bool)
- func (s KeyedSet[K, V]) GetByKey(key K) (V, bool)
- func (s *KeyedSet[K, V]) Include(vs ...V)
- func (s *KeyedSet[K, V]) IncludeSeq(seq seqs.Seq[V])
- func (s KeyedSet[K, V]) Len() int
- type MapKeySet
- type Modifiable
- type SetOf
- func ComplementOf[Set SetOf[Item], Item any](s Set) SetOf[Item]
- func IntersectionOf[SetA, SetB SetOf[Item], Item any](setA SetA, setB SetB) SetOf[Item]
- func Map[Set SetOf[U], OuterItem, U any](set Set, mappingFn func(OuterItem) U) SetOf[OuterItem]
- func RelativeComplementOf[SetA, SetB SetOf[Item], Item any](setA SetA, setB SetB) SetOf[Item]
- func UnionOf[SetA, SetB SetOf[Item], Item any](setA SetA, setB SetB) SetOf[Item]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AreEqual ¶
func AreEqual[SetA, SetB CountableSetOf[T], T any](setA SetA, setB SetB) bool
AreEqual returns true if the specified sets contain the same elements.
func CardinalityOf ¶
func CardinalityOf[T any](s CountableSetOf[T]) int
CardinalityOf returns the cardinality of the set.
Calling it on an infinite set will result in an infinite loop.
func ContainsAllOf ¶ added in v0.5.0
ContainsAllOf returns true if s contains all of the specified values
func ContainsAnyOf ¶
ContainsAnyOf returns true if s contains any of the specified values
func QuickCardinalityOf ¶
func QuickCardinalityOf[T any](s CountableSetOf[T]) (int, bool)
QuickCardinalityOf returns the cardinality of the set if it can be determined without counting its elements.
Types ¶
type CountableSetOf ¶
CountableSetOf defines the interface of a countable set of T.
func CountableIntersectionOf ¶
func CountableIntersectionOf[SetA, SetB CountableSetOf[Item], Item any](setA SetA, setB SetB) CountableSetOf[Item]
CountableIntersectionOf returns the intersection of the two specified countable sets.
func CountableRelativeComplementOf ¶
func CountableRelativeComplementOf[SetA, SetB CountableSetOf[Item], Item any](setA SetA, setB SetB) CountableSetOf[Item]
CountableRelativeComplementOf returns the countable relative complement of set A in set B.
func CountableUnionOf ¶
func CountableUnionOf[SetA, SetB CountableSetOf[Item], Item any](setA SetA, setB SetB) CountableSetOf[Item]
CountableUnionOf returns the union of the two specified countable sets.
type HashSet ¶
type HashSet[T comparable] struct { MapKeySet[map[T]struct{}, T, struct{}] }
func HashSetFromSeq ¶
func HashSetFromSeq[T comparable](seq seqs.Seq[T]) (res HashSet[T])
func HashSetFromSlice ¶ added in v0.3.1
func HashSetFromSlice[T comparable](vs []T) (res HashSet[T])
func HashSetFromValues ¶
func HashSetFromValues[T comparable](vs ...T) (res HashSet[T])
func (*HashSet[T]) ExcludeSeq ¶ added in v0.2.0
func (*HashSet[T]) ExcludeSet ¶ added in v0.5.0
func (*HashSet[T]) IncludeSeq ¶
type KeyedSet ¶ added in v0.3.2
type KeyedSet[K comparable, V any] struct { // contains filtered or unexported fields }
func KeyedSetFromSeq ¶ added in v0.3.2
func KeyedSetFromSeq[K comparable, V any](seq seqs.Seq[V], keyFn func(V) K) KeyedSet[K, V]
func KeyedSetFromSlice ¶ added in v0.3.2
func KeyedSetFromSlice[K comparable, V any](vs []V, keyFn func(V) K) KeyedSet[K, V]
func KeyedSetFromValues ¶ added in v0.3.2
func KeyedSetFromValues[K comparable, V any](keyFn func(V) K, vs ...V) (res KeyedSet[K, V])
func NewKeyedSet ¶ added in v0.3.2
func NewKeyedSet[K comparable, V any](keyFn func(V) K) KeyedSet[K, V]
func (KeyedSet[K, V]) Cardinality ¶ added in v0.3.2
func (*KeyedSet[K, V]) ExcludeSeq ¶ added in v0.3.2
func (KeyedSet[K, V]) ForEachUntil ¶ added in v0.3.2
func (*KeyedSet[K, V]) IncludeSeq ¶ added in v0.3.2
type MapKeySet ¶
type MapKeySet[M ~map[K]V, K comparable, V any] struct { Map M }
func MapKeySetFrom ¶
func MapKeySetFrom[M ~map[K]V, K comparable, V any](m M) MapKeySet[M, K, V]
func (MapKeySet[M, K, V]) Cardinality ¶
func (MapKeySet[M, K, V]) ForEachUntil ¶ added in v0.3.0
type Modifiable ¶ added in v0.2.0
type Modifiable[T any] interface { Exclude(...T) Include(...T) }
Modifiable defines how a set can be modified.
type SetOf ¶
SetOf defines the minimal interface of a set of T.
func ComplementOf ¶
ComplementOf returns the complement of the specified set.
func IntersectionOf ¶
IntersectionOf returns the intersection of the two specified sets.
func RelativeComplementOf ¶
RelativeComplementOf returns the relative complement of set A in set B.
This is also known as the set difference of B and A, denoted B \ A or B - A.