Documentation
¶
Overview ¶
Package sets provides generic set data structures.
These structures are not intended for general use; they only provide the operations required by official Dogmatiq engines and utilities.
Index ¶
- type Ordered
- func NewOrdered[T cmp.Ordered](members ...T) *Ordered[T]
- func NewOrderedFromKeys[T cmp.Ordered, unused any](seq iter.Seq2[T, unused]) *Ordered[T]
- func NewOrderedFromSeq[T cmp.Ordered](seq iter.Seq[T]) *Ordered[T]
- func NewOrderedFromValues[T cmp.Ordered, unused any](seq iter.Seq2[unused, T]) *Ordered[T]
- func (s *Ordered[T]) Add(members ...T)
- func (s *Ordered[T]) All() iter.Seq[T]
- func (s *Ordered[T]) Clear()
- func (s *Ordered[T]) Clone() *Ordered[T]
- func (s *Ordered[T]) Has(members ...T) bool
- func (s *Ordered[T]) Intersection(x *Ordered[T]) *Ordered[T]
- func (s *Ordered[T]) IsEqual(x *Ordered[T]) bool
- func (s *Ordered[T]) IsStrictSubset(x *Ordered[T]) bool
- func (s *Ordered[T]) IsStrictSuperset(x *Ordered[T]) bool
- func (s *Ordered[T]) IsSubset(x *Ordered[T]) bool
- func (s *Ordered[T]) IsSuperset(x *Ordered[T]) bool
- func (s *Ordered[T]) Len() int
- func (s *Ordered[T]) Remove(members ...T)
- func (s *Ordered[T]) Reverse() iter.Seq[T]
- func (s *Ordered[T]) Select(pred func(T) bool) *Ordered[T]
- func (s *Ordered[T]) Union(x *Ordered[T]) *Ordered[T]
- type OrderedByComparator
- func NewOrderedByComparator[T any, C constraints.Comparator[T]](members ...T) *OrderedByComparator[T, C]
- func NewOrderedByComparatorFromKeys[T any, C constraints.Comparator[T], unused any](seq iter.Seq2[T, unused]) *OrderedByComparator[T, C]
- func NewOrderedByComparatorFromSeq[T any, C constraints.Comparator[T]](seq iter.Seq[T]) *OrderedByComparator[T, C]
- func NewOrderedByComparatorFromValues[T any, C constraints.Comparator[T], unused any](seq iter.Seq2[unused, T]) *OrderedByComparator[T, C]
- func (s *OrderedByComparator[T, C]) Add(members ...T)
- func (s *OrderedByComparator[T, C]) All() iter.Seq[T]
- func (s *OrderedByComparator[T, C]) Clear()
- func (s *OrderedByComparator[T, C]) Clone() *OrderedByComparator[T, C]
- func (s *OrderedByComparator[T, C]) Has(members ...T) bool
- func (s *OrderedByComparator[T, C]) Intersection(x *OrderedByComparator[T, C]) *OrderedByComparator[T, C]
- func (s *OrderedByComparator[T, C]) IsEqual(x *OrderedByComparator[T, C]) bool
- func (s *OrderedByComparator[T, C]) IsStrictSubset(x *OrderedByComparator[T, C]) bool
- func (s *OrderedByComparator[T, C]) IsStrictSuperset(x *OrderedByComparator[T, C]) bool
- func (s *OrderedByComparator[T, C]) IsSubset(x *OrderedByComparator[T, C]) bool
- func (s *OrderedByComparator[T, C]) IsSuperset(x *OrderedByComparator[T, C]) bool
- func (s *OrderedByComparator[T, C]) Len() int
- func (s *OrderedByComparator[T, C]) Remove(members ...T)
- func (s *OrderedByComparator[T, C]) Reverse() iter.Seq[T]
- func (s *OrderedByComparator[T, C]) Select(pred func(T) bool) *OrderedByComparator[T, C]
- func (s *OrderedByComparator[T, C]) Union(x *OrderedByComparator[T, C]) *OrderedByComparator[T, C]
- type OrderedByMember
- func NewOrderedByMember[T constraints.Ordered[T]](members ...T) *OrderedByMember[T]
- func NewOrderedByMemberFromKeys[T constraints.Ordered[T], unused any](seq iter.Seq2[T, unused]) *OrderedByMember[T]
- func NewOrderedByMemberFromSeq[T constraints.Ordered[T]](seq iter.Seq[T]) *OrderedByMember[T]
- func NewOrderedByMemberFromValues[T constraints.Ordered[T], unused any](seq iter.Seq2[unused, T]) *OrderedByMember[T]
- func (s *OrderedByMember[T]) Add(members ...T)
- func (s *OrderedByMember[T]) All() iter.Seq[T]
- func (s *OrderedByMember[T]) Clear()
- func (s *OrderedByMember[T]) Clone() *OrderedByMember[T]
- func (s *OrderedByMember[T]) Has(members ...T) bool
- func (s *OrderedByMember[T]) Intersection(x *OrderedByMember[T]) *OrderedByMember[T]
- func (s *OrderedByMember[T]) IsEqual(x *OrderedByMember[T]) bool
- func (s *OrderedByMember[T]) IsStrictSubset(x *OrderedByMember[T]) bool
- func (s *OrderedByMember[T]) IsStrictSuperset(x *OrderedByMember[T]) bool
- func (s *OrderedByMember[T]) IsSubset(x *OrderedByMember[T]) bool
- func (s *OrderedByMember[T]) IsSuperset(x *OrderedByMember[T]) bool
- func (s *OrderedByMember[T]) Len() int
- func (s *OrderedByMember[T]) Remove(members ...T)
- func (s *OrderedByMember[T]) Reverse() iter.Seq[T]
- func (s *OrderedByMember[T]) Select(pred func(T) bool) *OrderedByMember[T]
- func (s *OrderedByMember[T]) Union(x *OrderedByMember[T]) *OrderedByMember[T]
- type Proto
- func (s *Proto[T]) Add(members ...T)
- func (s *Proto[T]) All() iter.Seq[T]
- func (s *Proto[T]) Clear()
- func (s *Proto[T]) Clone() *Proto[T]
- func (s *Proto[T]) Has(members ...T) bool
- func (s *Proto[T]) Intersection(x *Proto[T]) *Proto[T]
- func (s *Proto[T]) IsEqual(x *Proto[T]) bool
- func (s *Proto[T]) IsStrictSubset(x *Proto[T]) bool
- func (s *Proto[T]) IsStrictSuperset(x *Proto[T]) bool
- func (s *Proto[T]) IsSubset(x *Proto[T]) bool
- func (s *Proto[T]) IsSuperset(x *Proto[T]) bool
- func (s *Proto[T]) Len() int
- func (s *Proto[T]) Remove(members ...T)
- func (s *Proto[T]) Select(pred func(T) bool) *Proto[T]
- func (s *Proto[T]) Union(x *Proto[T]) *Proto[T]
- type Set
- func (s *Set[T]) Add(members ...T)
- func (s *Set[T]) All() iter.Seq[T]
- func (s *Set[T]) Clear()
- func (s *Set[T]) Clone() *Set[T]
- func (s *Set[T]) Has(members ...T) bool
- func (s *Set[T]) Intersection(x *Set[T]) *Set[T]
- func (s *Set[T]) IsEqual(x *Set[T]) bool
- func (s *Set[T]) IsStrictSubset(x *Set[T]) bool
- func (s *Set[T]) IsStrictSuperset(x *Set[T]) bool
- func (s *Set[T]) IsSubset(x *Set[T]) bool
- func (s *Set[T]) IsSuperset(x *Set[T]) bool
- func (s *Set[T]) Len() int
- func (s *Set[T]) Remove(members ...T)
- func (s *Set[T]) Select(pred func(T) bool) *Set[T]
- func (s *Set[T]) Union(x *Set[T]) *Set[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ordered ¶
Ordered is an ordered set of unique T values.
func NewOrdered ¶
NewOrdered returns an Ordered containing the given members.
func NewOrderedFromKeys ¶ added in v0.16.0
NewOrderedFromKeys returns an Ordered containing the keys yielded by the given sequence.
func NewOrderedFromSeq ¶ added in v0.16.0
NewOrderedFromSeq returns an Ordered containing the values yielded by the given sequence.
func NewOrderedFromValues ¶ added in v0.16.0
NewOrderedFromValues returns an Ordered containing the values yielded by the given sequence.
func (*Ordered[T]) Add ¶
func (s *Ordered[T]) Add(members ...T)
Add adds the given members to the set.
func (*Ordered[T]) Intersection ¶ added in v0.16.0
Intersection returns a set containing members that are in both s and x.
func (*Ordered[T]) IsStrictSubset ¶
IsStrictSubset returns true if x has all of the members of s and at least one member that is not in s.
func (*Ordered[T]) IsStrictSuperset ¶
IsStrictSuperset returns true if s has all of the members of x and at least one member that is not in x.
func (*Ordered[T]) IsSuperset ¶
IsSuperset returns true if s has all of the members of x.
func (*Ordered[T]) Remove ¶
func (s *Ordered[T]) Remove(members ...T)
Remove removes the given members from the set.
func (*Ordered[T]) Reverse ¶
Reverse returns a sequence that yields all members of the set in reverse order.
type OrderedByComparator ¶
type OrderedByComparator[T any, C constraints.Comparator[T]] struct { // contains filtered or unexported fields }
OrderedByComparator is an ordered set of unique T values where the ordering is defined by a separate comparitor type.
func NewOrderedByComparator ¶
func NewOrderedByComparator[T any, C constraints.Comparator[T]](members ...T) *OrderedByComparator[T, C]
NewOrderedByComparator returns an OrderedByComparator containing the given members.
func NewOrderedByComparatorFromKeys ¶ added in v0.16.0
func NewOrderedByComparatorFromKeys[T any, C constraints.Comparator[T], unused any](seq iter.Seq2[T, unused]) *OrderedByComparator[T, C]
NewOrderedByComparatorFromKeys returns an OrderedByComparator containing the keys yielded by the given sequence.
func NewOrderedByComparatorFromSeq ¶ added in v0.16.0
func NewOrderedByComparatorFromSeq[T any, C constraints.Comparator[T]](seq iter.Seq[T]) *OrderedByComparator[T, C]
NewOrderedByComparatorFromSeq returns an OrderedByComparator containing the values yielded by the given sequence.
func NewOrderedByComparatorFromValues ¶ added in v0.16.0
func NewOrderedByComparatorFromValues[T any, C constraints.Comparator[T], unused any](seq iter.Seq2[unused, T]) *OrderedByComparator[T, C]
NewOrderedByComparatorFromValues returns an OrderedByComparator containing the values yielded by the given sequence.
func (*OrderedByComparator[T, C]) Add ¶
func (s *OrderedByComparator[T, C]) Add(members ...T)
Add adds the given members to the set.
func (*OrderedByComparator[T, C]) All ¶
func (s *OrderedByComparator[T, C]) All() iter.Seq[T]
All returns a sequence that yields all members of the set in order.
func (*OrderedByComparator[T, C]) Clear ¶
func (s *OrderedByComparator[T, C]) Clear()
Clear removes all members from the set.
func (*OrderedByComparator[T, C]) Clone ¶
func (s *OrderedByComparator[T, C]) Clone() *OrderedByComparator[T, C]
Clone returns a shallow copy of the set.
func (*OrderedByComparator[T, C]) Has ¶
func (s *OrderedByComparator[T, C]) Has(members ...T) bool
Has returns true if all of the given values are members of the set.
func (*OrderedByComparator[T, C]) Intersection ¶ added in v0.16.0
func (s *OrderedByComparator[T, C]) Intersection(x *OrderedByComparator[T, C]) *OrderedByComparator[T, C]
Intersection returns a set containing members that are in both s and x.
func (*OrderedByComparator[T, C]) IsEqual ¶
func (s *OrderedByComparator[T, C]) IsEqual(x *OrderedByComparator[T, C]) bool
IsEqual returns true if s and x have the same members.
func (*OrderedByComparator[T, C]) IsStrictSubset ¶
func (s *OrderedByComparator[T, C]) IsStrictSubset(x *OrderedByComparator[T, C]) bool
IsStrictSubset returns true if x has all of the members of s and at least one member that is not in s.
func (*OrderedByComparator[T, C]) IsStrictSuperset ¶
func (s *OrderedByComparator[T, C]) IsStrictSuperset(x *OrderedByComparator[T, C]) bool
IsStrictSuperset returns true if s has all of the members of x and at least one member that is not in x.
func (*OrderedByComparator[T, C]) IsSubset ¶
func (s *OrderedByComparator[T, C]) IsSubset(x *OrderedByComparator[T, C]) bool
IsSubset returns true if x has all of the members of s.
func (*OrderedByComparator[T, C]) IsSuperset ¶
func (s *OrderedByComparator[T, C]) IsSuperset(x *OrderedByComparator[T, C]) bool
IsSuperset returns true if s has all of the members of x.
func (*OrderedByComparator[T, C]) Len ¶
func (s *OrderedByComparator[T, C]) Len() int
Len returns the number of members in the set.
func (*OrderedByComparator[T, C]) Remove ¶
func (s *OrderedByComparator[T, C]) Remove(members ...T)
Remove removes the given members from the set.
func (*OrderedByComparator[T, C]) Reverse ¶
func (s *OrderedByComparator[T, C]) Reverse() iter.Seq[T]
Reverse returns a sequence that yields all members of the set in reverse order.
func (*OrderedByComparator[T, C]) Select ¶
func (s *OrderedByComparator[T, C]) Select(pred func(T) bool) *OrderedByComparator[T, C]
Select returns the subset of s containing members for which the given predicate function returns true.
func (*OrderedByComparator[T, C]) Union ¶
func (s *OrderedByComparator[T, C]) Union(x *OrderedByComparator[T, C]) *OrderedByComparator[T, C]
Union returns a set containing all members of s and x.
type OrderedByMember ¶
type OrderedByMember[T constraints.Ordered[T]] struct { // contains filtered or unexported fields }
OrderedByMember is an ordered set of unique T values with the order defined by the T.Compare method.
func NewOrderedByMember ¶
func NewOrderedByMember[T constraints.Ordered[T]](members ...T) *OrderedByMember[T]
NewOrderedByMember returns an OrderedByMember containing the given members.
func NewOrderedByMemberFromKeys ¶ added in v0.16.0
func NewOrderedByMemberFromKeys[T constraints.Ordered[T], unused any](seq iter.Seq2[T, unused]) *OrderedByMember[T]
NewOrderedByMemberFromKeys returns an OrderedByMember containing the keys yielded by the given sequence.
func NewOrderedByMemberFromSeq ¶ added in v0.16.0
func NewOrderedByMemberFromSeq[T constraints.Ordered[T]](seq iter.Seq[T]) *OrderedByMember[T]
NewOrderedByMemberFromSeq returns an OrderedByMember containing the values yielded by the given sequence.
func NewOrderedByMemberFromValues ¶ added in v0.16.0
func NewOrderedByMemberFromValues[T constraints.Ordered[T], unused any](seq iter.Seq2[unused, T]) *OrderedByMember[T]
NewOrderedByMemberFromValues returns an OrderedByMember containing the values yielded by the given sequence.
func (*OrderedByMember[T]) Add ¶
func (s *OrderedByMember[T]) Add(members ...T)
Add adds the given members to the set.
func (*OrderedByMember[T]) All ¶
func (s *OrderedByMember[T]) All() iter.Seq[T]
All returns a sequence that yields all members of the set in order.
func (*OrderedByMember[T]) Clear ¶
func (s *OrderedByMember[T]) Clear()
Clear removes all members from the set.
func (*OrderedByMember[T]) Clone ¶
func (s *OrderedByMember[T]) Clone() *OrderedByMember[T]
Clone returns a shallow copy of the set.
func (*OrderedByMember[T]) Has ¶
func (s *OrderedByMember[T]) Has(members ...T) bool
Has returns true if all of the given values are members of the set.
func (*OrderedByMember[T]) Intersection ¶ added in v0.16.0
func (s *OrderedByMember[T]) Intersection(x *OrderedByMember[T]) *OrderedByMember[T]
Intersection returns a set containing members that are in both s and x.
func (*OrderedByMember[T]) IsEqual ¶
func (s *OrderedByMember[T]) IsEqual(x *OrderedByMember[T]) bool
IsEqual returns true if s and x have the same members.
func (*OrderedByMember[T]) IsStrictSubset ¶
func (s *OrderedByMember[T]) IsStrictSubset(x *OrderedByMember[T]) bool
IsStrictSubset returns true if x has all of the members of s and at least one member that is not in s.
func (*OrderedByMember[T]) IsStrictSuperset ¶
func (s *OrderedByMember[T]) IsStrictSuperset(x *OrderedByMember[T]) bool
IsStrictSuperset returns true if s has all of the members of x and at least one member that is not in x.
func (*OrderedByMember[T]) IsSubset ¶
func (s *OrderedByMember[T]) IsSubset(x *OrderedByMember[T]) bool
IsSubset returns true if x has all of the members of s.
func (*OrderedByMember[T]) IsSuperset ¶
func (s *OrderedByMember[T]) IsSuperset(x *OrderedByMember[T]) bool
IsSuperset returns true if s has all of the members of x.
func (*OrderedByMember[T]) Len ¶
func (s *OrderedByMember[T]) Len() int
Len returns the number of members in the set.
func (*OrderedByMember[T]) Remove ¶
func (s *OrderedByMember[T]) Remove(members ...T)
Remove removes the given members from the set.
func (*OrderedByMember[T]) Reverse ¶
func (s *OrderedByMember[T]) Reverse() iter.Seq[T]
Reverse returns a sequence that yields all members of the set in reverse order.
func (*OrderedByMember[T]) Select ¶
func (s *OrderedByMember[T]) Select(pred func(T) bool) *OrderedByMember[T]
Select returns the subset of s containing members for which the given predicate function returns true.
func (*OrderedByMember[T]) Union ¶
func (s *OrderedByMember[T]) Union(x *OrderedByMember[T]) *OrderedByMember[T]
Union returns a set containing all members of s and x.
type Proto ¶
Proto is an unordered set of unique Protocol Buffers messages of type T.
T must be a pointer type that implements proto.Message.
Equality is determined based on the serialized form of the message, and so is subject to the caveats described by https://protobuf.dev/programming-guides/encoding/#implications.
At time of writing, the Go implementation provides deterministic output for the same input within the same binary/process, which is sufficient for the purposes of this type.
func NewProtoFromKeys ¶ added in v0.16.0
NewProtoFromKeys returns a Proto containing the keys yielded by the given sequence.
func NewProtoFromSeq ¶ added in v0.16.0
NewProtoFromSeq returns a Proto containing the values yielded by the given sequence.
func NewProtoFromValues ¶ added in v0.16.0
NewProtoFromValues returns a Proto containing the values yielded by the given sequence.
func (*Proto[T]) All ¶
All returns a sequence that yields all members of the set in no particular order.
func (*Proto[T]) Intersection ¶ added in v0.16.0
Intersection returns a set containing members that are in both s and x.
func (*Proto[T]) IsStrictSubset ¶
IsStrictSubset returns true if x has all of the members of s and at least one member that is not in s.
func (*Proto[T]) IsStrictSuperset ¶
IsStrictSuperset returns true if s has all of the members of x and at least one member that is not in x.
func (*Proto[T]) IsSuperset ¶
IsSuperset returns true if s has all of the members of x.
func (*Proto[T]) Remove ¶
func (s *Proto[T]) Remove(members ...T)
Remove removes the given members from the set.
type Set ¶
type Set[T comparable] struct { // contains filtered or unexported fields }
Set is an unordered set of unique T values.
func New ¶
func New[T comparable](members ...T) *Set[T]
New returns a Set containing the given members.
func NewFromKeys ¶ added in v0.16.0
func NewFromKeys[K comparable, unused any](seq iter.Seq2[K, unused]) *Set[K]
NewFromKeys returns a Set containing the keys yielded by the given sequence.
func NewFromSeq ¶ added in v0.16.0
func NewFromSeq[T comparable](seq iter.Seq[T]) *Set[T]
NewFromSeq returns a Set containing the values yielded by the given sequence.
func NewFromValues ¶ added in v0.16.0
func NewFromValues[T comparable, unused any](seq iter.Seq2[unused, T]) *Set[T]
NewFromValues returns a Set containing the values yielded by the given sequence.
func (*Set[T]) All ¶
All returns a sequence that yields all members of the set in no particular order.
func (*Set[T]) Intersection ¶ added in v0.16.0
Intersection returns a set containing members that are in both s and x.
func (*Set[T]) IsStrictSubset ¶
IsStrictSubset returns true if x has all of the members of s and at least one member that is not in s.
func (*Set[T]) IsStrictSuperset ¶
IsStrictSuperset returns true if s has all of the members of x and at least one member that is not in x.
func (*Set[T]) IsSuperset ¶
IsSuperset returns true if s has all of the members of x.
func (*Set[T]) Remove ¶
func (s *Set[T]) Remove(members ...T)
Remove removes the given members from the set.