Skip to content

Commit

Permalink
Export 4 set-operation functions
Browse files Browse the repository at this point in the history
  • Loading branch information
b97tsk committed Jan 23, 2024
1 parent 67235b8 commit 4dfd528
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions difference.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import "sort"

// Difference returns the set of elements that are in x, but not in y.
func (x Set[E]) Difference(y Set[E]) Set[E] {
return differenceInto(nil, x, y)
return DifferenceInto(nil, x, y)
}

// Difference returns the set of elements that are in sets[0], but not in
// any of sets[1:]. If sets is empty, Difference returns an empty set.
func Difference[E Elem[E]](sets ...Set[E]) Set[E] {
return combine(differenceInto, sets...)
return combine(DifferenceInto, sets...)
}

// differenceInto returns the set of elements that are in x, but not in y,
// DifferenceInto returns the set of elements that are in x, but not in y,
// overwriting z. z must not be x or y; z must not be used after.
func differenceInto[E Elem[E]](z, x, y Set[E]) Set[E] {
func DifferenceInto[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

inv := false
Expand Down
8 changes: 4 additions & 4 deletions intersection.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import "sort"

// Intersection returns the set of elements that are in both x and y.
func (x Set[E]) Intersection(y Set[E]) Set[E] {
return intersectionInto(nil, x, y)
return IntersectionInto(nil, x, y)
}

// Intersection returns the set of elements that are in each of sets.
func Intersection[E Elem[E]](sets ...Set[E]) Set[E] {
return combine(intersectionInto, sets...)
return combine(IntersectionInto, sets...)
}

// intersectionInto returns the set of elements that are in both x and y,
// IntersectionInto returns the set of elements that are in both x and y,
// overwriting z. z must not be x or y; z must not be used after.
func intersectionInto[E Elem[E]](z, x, y Set[E]) Set[E] {
func IntersectionInto[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

for {
Expand Down
8 changes: 4 additions & 4 deletions symdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import "sort"
// SymmetricDifference returns the set of elements that are in one of x and y,
// but not in both.
func (x Set[E]) SymmetricDifference(y Set[E]) Set[E] {
return symmetricDifferenceInto(nil, x, y)
return SymmetricDifferenceInto(nil, x, y)
}

// SymmetricDifference returns the set of elements that are in an odd number
// of sets.
func SymmetricDifference[E Elem[E]](sets ...Set[E]) Set[E] {
return combine(symmetricDifferenceInto, sets...)
return combine(SymmetricDifferenceInto, sets...)
}

// symmetricDifferenceInto returns the set of elements that are in one of x and
// SymmetricDifferenceInto returns the set of elements that are in one of x and
// y, but not in both, overwriting z. z must not be x or y; z must not be used
// after.
func symmetricDifferenceInto[E Elem[E]](z, x, y Set[E]) Set[E] {
func SymmetricDifferenceInto[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

for {
Expand Down
8 changes: 4 additions & 4 deletions union.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import "sort"

// Union returns the set of elements that are in either x, or y, or both.
func (x Set[E]) Union(y Set[E]) Set[E] {
return unionInto(nil, x, y)
return UnionInto(nil, x, y)
}

// Union returns the set of elements that are in any of sets.
func Union[E Elem[E]](sets ...Set[E]) Set[E] {
return combine(unionInto, sets...)
return combine(UnionInto, sets...)
}

// unionInto returns the set of elements that are in either x, or y, or both,
// UnionInto returns the set of elements that are in either x, or y, or both,
// overwriting z. z must not be x or y; z must not be used after.
func unionInto[E Elem[E]](z, x, y Set[E]) Set[E] {
func UnionInto[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

for {
Expand Down

0 comments on commit 4dfd528

Please sign in to comment.