Documentation ¶
Overview ¶
Package sequential provides sequential implementations of the functions provided by the parallel and speculative packages. This is useful for testing and debugging.
It is not recommended to use the implementations of this package for any other purpose, because they are almost certainly too inefficient for regular sequential programs.
Index ¶
- func And(predicates ...func() bool) bool
- func Do(thunks ...func())
- func Or(predicates ...func() bool) bool
- func Range(low, high, n int, f func(low, high int))
- func RangeAnd(low, high, n int, f func(low, high int) bool) bool
- func RangeOr(low, high, n int, f func(low, high int) bool) bool
- func RangeReduce(low, high, n int, reduce func(low, high int) interface{}, ...) interface{}
- func RangeReduceFloat64(low, high, n int, reduce func(low, high int) float64, ...) float64
- func RangeReduceFloat64Product(low, high, n int, reduce func(low, high int) float64) float64
- func RangeReduceFloat64Sum(low, high, n int, reduce func(low, high int) float64) float64
- func RangeReduceInt(low, high, n int, reduce func(low, high int) int, join func(x, y int) int) int
- func RangeReduceIntProduct(low, high, n int, reduce func(low, high int) int) int
- func RangeReduceIntSum(low, high, n int, reduce func(low, high int) int) int
- func RangeReduceString(low, high, n int, reduce func(low, high int) string, ...) string
- func RangeReduceStringSum(low, high, n int, reduce func(low, high int) string) string
- func Reduce(join func(x, y interface{}) interface{}, firstFunction func() interface{}, ...) interface{}
- func ReduceFloat64(join func(x, y float64) float64, firstFunction func() float64, ...) float64
- func ReduceFloat64Product(functions ...func() float64) float64
- func ReduceFloat64Sum(functions ...func() float64) float64
- func ReduceInt(join func(x, y int) int, firstFunction func() int, moreFunctions ...func() int) int
- func ReduceIntProduct(functions ...func() int) int
- func ReduceIntSum(functions ...func() int) int
- func ReduceString(join func(x, y string) string, firstFunction func() string, ...) string
- func ReduceStringSum(functions ...func() string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
And receives zero or more predicate functions and executes them sequentially, combining all return values with the && operator, with true as the default return value.
func Or ¶
Or receives zero or more predicate functions and executes them sequentially, combining all return values with the || operator, with false as the default return value.
func Range ¶
Range receives a range, a batch count n, and a range function f, divides the range into batches, and invokes the range function for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
Range panics if high < low, or if n < 0.
func RangeAnd ¶
RangeAnd receives a range, a batch count n, and a range predicate function f, divides the range into batches, and invokes the range predicate for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeAnd returns by combining all return values with the && operator.
RangeAnd panics if high < low, or if n < 0.
func RangeOr ¶
RangeOr receives a range, a batch count n, and a range predicate function f, divides the range into batches, and invokes the range predicate for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeOr returns by combining all return values with the || operator.
RangeOr panics if high < low, or if n < 0.
func RangeReduce ¶
func RangeReduce( low, high, n int, reduce func(low, high int) interface{}, join func(x, y interface{}) interface{}, ) interface{}
RangeReduce receives a range, a batch count, a range reduce function, and a join function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then combined by repeated invocations of join.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeReduce panics if high < low, or if n < 0.
func RangeReduceFloat64 ¶
func RangeReduceFloat64( low, high, n int, reduce func(low, high int) float64, join func(x, y float64) float64, ) float64
RangeReduceFloat64 receives a range, a batch count n, a range reducer function, and a join function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then combined by repeated invocations of join.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
Float64RangeReduce panics if high < low, or if n < 0.
func RangeReduceFloat64Product ¶
RangeReduceFloat64Product receives a range, a batch count n, and a range reducer function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then multiplied with each other.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeReduceFloat64Product panics if high < low, or if n < 0.
func RangeReduceFloat64Sum ¶
RangeReduceFloat64Sum receives a range, a batch count n, and a range reducer function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then added together.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeReduceFloat64Sum panics if high < low, or if n < 0.
func RangeReduceInt ¶
func RangeReduceInt( low, high, n int, reduce func(low, high int) int, join func(x, y int) int, ) int
RangeReduceInt receives a range, a batch count n, a range reducer function, and a join function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then combined by repeated invocations of join.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
IntRangeReduce panics if high < low, or if n < 0.
func RangeReduceIntProduct ¶
RangeReduceIntProduct receives a range, a batch count n, and a range reducer function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then multiplied with each other.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeReduceIntProduct panics if high < low, or if n < 0.
func RangeReduceIntSum ¶
RangeReduceIntSum receives a range, a batch count n, and a range reducer function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then added together.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeReduceIntSum panics if high < low, or if n < 0.
func RangeReduceString ¶
func RangeReduceString( low, high, n int, reduce func(low, high int) string, join func(x, y string) string, ) string
RangeReduceString receives a range, a batch count n, a range reducer function, and a join function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then combined by repeated invocations of join.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
StringRangeReduce panics if high < low, or if n < 0.
func RangeReduceStringSum ¶
RangeReduceStringSum receives a range, a batch count n, and a range reducer function, divides the range into batches, and invokes the range reducer for each of these batches sequentially, covering the half-open interval from low to high, including low but excluding high. The results of the range reducer invocations are then concatenated together.
The range is specified by a low and high integer, with low <= high. The batches are determined by dividing up the size of the range (high - low) by n. If n is 0, a reasonable default is used that takes runtime.GOMAXPROCS(0) into account.
RangeReduceStringSum panics if high < low, or if n < 0.
func Reduce ¶
func Reduce( join func(x, y interface{}) interface{}, firstFunction func() interface{}, moreFunctions ...func() interface{}, ) interface{}
Reduce receives one or more functions, executes them sequentially, and combines their results sequentially.
Partial results are combined with the join function.
func ReduceFloat64 ¶
func ReduceFloat64( join func(x, y float64) float64, firstFunction func() float64, moreFunctions ...func() float64, ) float64
ReduceFloat64 receives one or more functions, executes them sequentially, and combines their results sequentially.
Partial results are combined with the join function.
func ReduceFloat64Product ¶
ReduceFloat64Product receives zero or more functions, executes them sequentially, and multiplies their results sequentially.
func ReduceFloat64Sum ¶
ReduceFloat64Sum receives zero or more functions, executes them sequentially, and adds their results sequentially.
func ReduceInt ¶
func ReduceInt( join func(x, y int) int, firstFunction func() int, moreFunctions ...func() int, ) int
ReduceInt receives one or more functions, executes them sequentially, and combines their results sequentially.
Partial results are combined with the join function.
func ReduceIntProduct ¶
ReduceIntProduct receives zero or more functions, executes them sequentially, and multiplies their results sequentially.
func ReduceIntSum ¶
ReduceIntSum receives zero or more functions, executes them sequentially, and adds their results sequentially.
func ReduceString ¶
func ReduceString( join func(x, y string) string, firstFunction func() string, moreFunctions ...func() string, ) string
ReduceString receives one or more functions, executes them in parallel, and combines their results in parallel.
Partial results are combined with the join function.
func ReduceStringSum ¶
ReduceStringSum receives zero or more functions, executes them in parallel, and concatenates their results in parallel.
Types ¶
This section is empty.