sequential

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: BSD-3-Clause Imports: 2 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And(predicates ...func() bool) bool

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 Do

func Do(thunks ...func())

Do receives zero or more thunks and executes them sequentially.

func Or

func Or(predicates ...func() bool) bool

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

func Range(
	low, high, n int,
	f func(low, high int),
)

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

func RangeAnd(
	low, high, n int,
	f func(low, high int) bool,
) bool

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

func RangeOr(
	low, high, n int,
	f func(low, high int) bool,
) bool

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

func RangeReduceFloat64Product(
	low, high, n int,
	reduce func(low, high int) float64,
) float64

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

func RangeReduceFloat64Sum(
	low, high, n int,
	reduce func(low, high int) float64,
) float64

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

func RangeReduceIntProduct(
	low, high, n int,
	reduce func(low, high int) int,
) int

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

func RangeReduceIntSum(
	low, high, n int,
	reduce func(low, high int) int,
) int

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

func RangeReduceStringSum(
	low, high, n int,
	reduce func(low, high int) string,
) string

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

func ReduceFloat64Product(functions ...func() float64) float64

ReduceFloat64Product receives zero or more functions, executes them sequentially, and multiplies their results sequentially.

func ReduceFloat64Sum

func ReduceFloat64Sum(functions ...func() float64) float64

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

func ReduceIntProduct(functions ...func() int) int

ReduceIntProduct receives zero or more functions, executes them sequentially, and multiplies their results sequentially.

func ReduceIntSum

func ReduceIntSum(functions ...func() int) int

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

func ReduceStringSum(functions ...func() string) string

ReduceStringSum receives zero or more functions, executes them in parallel, and concatenates their results in parallel.

Types

This section is empty.

Jump to

Keyboard shortcuts

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