Documentation ¶
Index ¶
- func AddUnique[E comparable, S ~[]E](s S, e E) S
- func AddUniqueFn[E any, S ~[]E](s S, e E, eq func(E, E) bool) S
- func Difference[E comparable, S ~[]E](x, y S) S
- func Disjoint[E comparable](x, y []E) bool
- func Equal[E comparable](x, y []E) bool
- func Intersect[E comparable, S ~[]E](x, y S) S
- func IntersectFn[E any, S ~[]E](x, y S, eq func(E, E) bool) S
- func StartsWithSet[E comparable](x, y []E) bool
- func Subset[E comparable](x, y []E) bool
- func Union[E comparable, S ~[]E](x, y S) S
- func UnionFn[E any, S ~[]E](x, y S, eq func(E, E) bool) S
- func Unique[E comparable, S ~[]E](x S) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUnique ¶
func AddUnique[E comparable, S ~[]E](s S, e E) S
AddUnique appends s unless it is already in the set
WARNING: it does append so usage must be: x = AddUnique(x, y)
func AddUniqueFn ¶
func Difference ¶
func Difference[E comparable, S ~[]E](x, y S) S
Difference returns the elements of x that are not in y.
WARNING: If y is empty, it returns the *original* x.
WARNING: duplicates in the inputs may give duplicates in the result
func Disjoint ¶
func Disjoint[E comparable](x, y []E) bool
Disjoint returns true if x and y have no elements in common. i.e. Intersect(x, y) is empty
func Equal ¶
func Equal[E comparable](x, y []E) bool
Equal returns true if x and y contain the same set of values.
func Intersect ¶
func Intersect[E comparable, S ~[]E](x, y S) S
Intersect returns a list of the values common to the inputs, the result is in the same order as the first argument (x).
WARNING: If x and y are the same list, it returns the *original*.
WARNING: duplicates in the inputs may give duplicates in the result
func IntersectFn ¶
func StartsWithSet ¶
func StartsWithSet[E comparable](x, y []E) bool
StartsWithSet returns true if x starts with a permutation of y
func Subset ¶
func Subset[E comparable](x, y []E) bool
Subset returns true is y is a subset of x i.e. x contains all of y
func Union ¶
func Union[E comparable, S ~[]E](x, y S) S
Union returns a combined list. If either input contains duplicates, so will the output. The order of x and y are preserved.
WARNING: If either x or y is empty, it returns the *original* of the other.
func Unique ¶
func Unique[E comparable, S ~[]E](x S) S
Unique returns a list with duplicates removed, retaining the original order.
NOTE: If there are no duplicates it returns the *original* list.
Types ¶
This section is empty.