sets

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseSet

func ChooseSet[T any](start, stopInclusive int, kind func(pair propcheck.SimpleRNG) (T, propcheck.SimpleRNG), lt func(l, r T) bool, eq func(l, r T) bool) func(propcheck.SimpleRNG) ([]T, propcheck.SimpleRNG)

Generates a set with A size in the indicated range using the given Gen lt - a predicate function that returns true if l is lexically less than r eq - a predicate function that returns true if l is equal to r Note that the returned set may not meet the minimum size requirement after de-duplication. This is impossible to handle in any general way(i.e. the set of bools with cardinality == 3).

func SetEquality added in v0.1.16

func SetEquality[T any](aa []T, bb []T, equality func(l, r T) bool) bool

The efficiency of this algorithm is O(N)

func SetIntersection added in v0.1.16

func SetIntersection[T any](a []T, b []T, lt, eq func(l, r T) bool) []T

Returns the intersection of set 'a' and 'b' The efficiency of this algorithm is O(5 * N)

func SetMinus added in v0.1.16

func SetMinus[T any](a []T, b []T, equality func(l, r T) bool) []T

Returns the set 'a' minus set 'b' The efficiency of this algorithm is O(N)

func SetUnion added in v0.1.16

func SetUnion[T any](a []T, b []T, lt, eq func(l, r T) bool) []T

Returns the set union of set 'a' and 'b'

func ToSet

func ToSet[T any](a []T, lt, eq func(l, r T) bool) []T

Makes a "real" set from an array. A "real" set is an array without duplicates based upon the given equality predicate. Note the set operations in arrays package do not depend on the array being "real". Making a set is expensive because it requires sorting and de-duplication. lt - a predicate function that returns true if l is lexically less than r eq - a predicate function that returns true if l is equal to r NOTE -- this is not a pure function. It mutates the input array a.

Types

This section is empty.

Jump to

Keyboard shortcuts

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